下面的代码是完美运行的代码的精确副本。不同之处在于,这段代码被放置在一个WCF服务应用项目中,而工作的代码来自Windows窗体应用程序项目。foreach中的代码是无法到达的,这很奇怪,因为我以前测试过这段代码,并且它可以返回正确的值。
public IEnumerable<Employee> GetStudentDetails(string username,string password)
{
var emp = agrDb.LoginAuthentication(username, password);//procedure in the database thats returning two values
//Namely: EmployeeFirstName and EmployeeLastName
List<Employee> trainerList = new List<Employee>();
foreach (var item in emp)
{
//unreachable code here
Employee employ = new Employee();
employ.EmployeeFirstName = item.EmployeeFirstName;
employ.EmployeeLastName = item.EmployeeLastName;
trainerList.Add(employ);
//trainerList.Add(item.EmployeeLastName);
}
return trainerList;
}