IQueryable<SystemGroup> systemGroupQuery;
systemGroupQuery = dbContext.SystemGroups.Select(x => new SystemGroup()
{
Id = x.Id,
Name = x.Name,
SmsAccountId = x.SmsAccountId,
SmsAccount = dbContext.SmsAccounts.Where(g => g.Id
== x.SmsAccountId).SingleOrDefault()
});
var systemGroups = systemGroupQuery.ToList();
转换为列表时,我收到错误“无法在LINQ to Entities查询中构造实体或复杂类型'Models.Context.SystemGroup'。”
答案 0 :(得分:0)
在.ToList()
之前添加.Select
要么
使用匿名对象并在.ToList()
Linq to entities不允许在苍蝇中构建复杂的类型对象