我正在尝试调用GetScanningLogOnSettings()
方法,该方法查询ScanningDepartments
表以获取部门信息,然后创建ApplicationLogOnModel
的实例,将查询结果分配给ApplicationLogOnModel
中的变量,并返回结果。
private ApplicationLogOnModel GetScanningLogOnSettings()
{
var mesEntity = new MESEntities();
var departments = from dept in mesEntity.ScanningDepartments
select dept.Department.ToList();
ApplicationLogOnModel depts = new ApplicationLogOnModel()
{
Department = departments
};
return depts;
}
这给了我:
"无法隐式转换类型
'System.Linq.IQueryable<System.Collections.Generic.List<char>>
到'System.Collections.Generic.List<Models.Department>'
尝试转换为列表,但遇到了一些问题。
dept.Department
返回一个字符串,而ApplicationLogOnModel.Department
不是字符串列表,而是Models.Department
实例的列表。 - Daniel Hilgarth