下面的代码是完美运行的代码的精确副本。不同之处在于此代码被放置在 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;
}