コード例 #1
0
 /// <summary>
 /// Optional: This method uses the stored procedure to retrieve a single employee from the database
 /// </summary>
 /// <param name="id">Integer value ID of the employee</param>
 /// <param name="useStoredProcedure">true = Yes</param>
 /// <returns>Employee</returns>
 public Employee GetEmployee(long id, bool useStoredProcedure)
 {
     try
     {
         using (var entity = new EmployeesEntities())
         {
             if (useStoredProcedure)
             {
                 var current = entity.GetEmployee(id).First();
                 return(new Employee
                 {
                     Active = current.Active,
                     Department = current.Department,
                     DOB = current.DOB,
                     Firstname = current.Firstname,
                     Gender = current.Gender,
                     Id = current.Id,
                     Lastname = current.Lastname
                 });
             }
             else
             {
                 return(GetEmployee(id));
             }
         }
     }
     catch { return(null); }
 }