实体框架包括()强类型 [英] Entity Framework Include() strongly typed
问题描述
有没有一种方法,使这种强烈的使用方法System.Data.Entity.Include类型?在下面升级的方法是一个的ICollection&下;>
公开的IEnumerable< EscalationType> GetAllTypes(){
Database.Configuration.LazyLoadingEnabled = FALSE;
返回Database.EscalationTypes
.INCLUDE(升级)
.INCLUDE(Escalation.Primary)
.INCLUDE(Escalation.Backup)
.INCLUDE(Escalation.Primary.ContactInformation)
.INCLUDE(Escalation.Backup.ContactInformation)了ToList()。
}
这是已经可以在实体框架4.1。
在这里看到对如何使用功能包括一个参考,它也显示了如何包含多个层次:<一href=\"http://msdn.microsoft.com/en-us/library/gg671236%28VS.103%29.aspx\">http://msdn.microsoft.com/en-us/library/gg671236(VS.103).aspx
强类型包括()
方法是一个扩展方法,所以你必须记住要申报使用System.Data.Entity的;
语句。
Is there a way to make this strongly typed using the System.Data.Entity.Include method? In the method below Escalation is a ICollection<>.
public IEnumerable<EscalationType> GetAllTypes() {
Database.Configuration.LazyLoadingEnabled = false;
return Database.EscalationTypes
.Include("Escalation")
.Include("Escalation.Primary")
.Include("Escalation.Backup")
.Include("Escalation.Primary.ContactInformation")
.Include("Escalation.Backup.ContactInformation").ToList();
}
This is already available in Entity Framework 4.1.
See here for a reference for how to use the include feature, it also shows how to include multiple levels: http://msdn.microsoft.com/en-us/library/gg671236(VS.103).aspx
The strongly typed Include()
method is an extension method so you have to remember to declare the using System.Data.Entity;
statement.
这篇关于实体框架包括()强类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!