سؤال

Was DbExtensions lib not included for EF 6.0? I have a generic repo that returns and IQueryable and I'd like to be able to call .Include(i => i.SomeEntity) on demaind when needed.

هل كانت مفيدة؟

المحلول

I'm going to answer my own question. You don't make a reference to System.Data.Entity for version 6 to get the DbExtensions. You need to reference the EntityFramework itself and add using System.Data.Entity at the top of your cs file and the .Include() will be there.

نصائح أخرى

For EF 6.0 these functions are now available in System.Data.Entity.QueryableExtensions within EntityFramework.dll:

public static IQueryable Include(this IQueryable source, string path);

public static IQueryable<T> Include<T>(this IQueryable<T> source, string path);

public static IQueryable<T> Include<T, TProperty>(this IQueryable<T> source, Expression<Func<T, TProperty>> path);

Add using System.Data.Entity;.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top