正如 OP 在评论中提到的,employee
和的模式employee_details
是这样的:
public class employee
{
public string Name {get;set;}
public string Department {get;set;}
}
public class employee_details
{
public string Address {get;set;}
public string Mobile {get;set;}
}
因此,在应用映射后,您的代码将类似于:
var query = objEmployee.sp_display().Select(s=> new ViewModel{
employees = new employee{
Name = s.Name //change the s.Name to the property name coming from your SP(if different)
Department = s.Department
},
employee_detail = new employee_detail{
Address = s.Address,
Mobile = s.Mobile
}}).ToList()
或者最好只是删除query
对象并使用 ,listEmployeeList
因为此列表本身也引用了 ,ViewModel
因此该query
对象是不必要的(除非您想对其进行一些其他过滤):
listEmployeeList = // the above code with .ToList();
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句