【发布时间】:2015-02-23 21:39:52
【问题描述】:
我已经实现了通用存储库。问题是我的主要返回类型中的虚拟类型为空。如何将它们包含在异步调用中? 这是我的类型:
public class Translation : Entity
{
public string Text { get; private set; }
public Guid TranslationKeyID { get; set; }
[ForeignKey("TranslationKeyID")]
public virtual TranslationKey TranslationKey { get; set; }
}
现在这是我希望 TranslationKey 实体也出现在我的结果中的方法,但我只得到 TranslationKeyId。
我的服务方法:
public async Task<List<TranslationDto>> ListTanslationsAsync()
{
var translations = await _translationRepository.GetAllAsync().
if (translations != null)
{
return translations.ProjectedAs<List<TranslationDto>>();
}
return null;
}
用什么来代替 GetAllAsync()??
【问题讨论】:
-
我通过进入存储库并添加一个自定义方法解决了这个问题,我可以在其中轻松使用
include
标签: c# linq entity-framework asynchronous