【发布时间】:2016-01-08 09:25:36
【问题描述】:
我有以下代码,可以正常工作且符合预期:
return profileEntities.Select(x => (ProfileDTO)new ProfileDTO()
{
Localizations = new List<ProfileLocalizationDTO>()
}
.InjectFrom(x)).ToList();
但是,我想更进一步,用来自 repo 的值填充 Localizations,如下所示:
return profileEntities.Select(x => (ProfileDTO)new ProfileDTO()
{
Localizations = _repoProfileLocalization
.Query(y => y.ProfileId == x.Id)
.Select(y => (ProfileLocalizationDTO)new ProfileLocalizationDTO().InjectFrom(y))
.ToList()
}
.InjectFrom(x)).ToList();
这会引发错误
“System.NotSupportedException”类型的异常发生在 EntityFramework.SqlServer.dll 但未在用户代码中处理
附加信息:LINQ to Entities 无法识别该方法 'System.Object InjectFrom(System.Object, System.Object[])' 方法,以及 此方法无法转换为商店表达式。
非常感谢任何建议。
【问题讨论】:
标签: c# entity-framework linq