Xav*_*nas 7 .net c# entity-framework entity-framework-5
我试图在Entity Framework模型中急于加载派生类的属性.
在包含使用Include()的属性之前,我已经阅读了所有 必须首先使用OfType()过滤集合的 地方:
var persons = Context.Persons
                     .OfType<Employee>()
                     .Include("Compensation")
我不知道如何让Include()工作,因为在我的情况下,Persons是DbSet,OfType()返回IQueryable而IQueryable没有定义Include()方法.
Den*_*nis 16
放置这个:
using System.Data.Entity;
进入你的使用列表,然后你将能够使用类中的Include扩展方法系列DbExtensions:
    public static IQueryable<T> Include<T, TProperty>(this IQueryable<T> source, Expression<Func<T, TProperty>> path) where T : class;
    public static IQueryable<T> Include<T>(this IQueryable<T> source, string path) where T : class;
    public static IQueryable Include(this IQueryable source, string path);
他们接受IQueryable作为第一个参数,并且也有强类型的,然后更好Include(String).
| 归档时间: | 
 | 
| 查看次数: | 2699 次 | 
| 最近记录: |