public Employee InsertAndReturn(Employee employee)
{
const string sql = @"INSERT INTO HR.Employee
(FirstName,
MiddleName,
LastName,
Title,
ManagerKey,
OfficePhone,
CellPhone
)
OUTPUT
Inserted.EmployeeKey,
Inserted.FirstName,
Inserted.MiddleName,
Inserted.LastName,
Inserted.Title,
Inserted.ManagerKey,
Inserted.OfficePhone,
Inserted.CellPhone,
Inserted.CreatedDate
VALUES (@FirstName,
@MiddleName,
@LastName,
@Title,
@ManagerKey,
@OfficePhone,
@CellPhone
);
";
using (var con = new SqlConnection(m_ConnectionString))
{
con.Open();
return con.Query<Employee>(sql, employee).First();
}
}