Ответ 1
это не в System.Linq. Добавить
using System.Data.Entity
Я использую сущность framework, и я не могу найти метод include, как в этом примере:
using(ArticleExtractorEntities db=new ArticleExtractorEntities())
{
Preference pref= db.Preferences.Include(
здесь я нахожу только функцию include с параметром (строковый путь), и я не нахожу другую перегрузку, так как я могу использовать Include с выражением лямбда?
это не в System.Linq. Добавить
using System.Data.Entity
Update. Для тех, кто смотрит, как он расширяет ваш запрос linq с помощью .Include()
Больше не существует:
using System.Data.Entity;
С netcoreapp1.0 это:
using Microsoft.EntityFrameworkCore;
Вы можете реализовать его как показано в этом сообщении в блоге:
public static class ObjectQueryExtension
{
public static ObjectQuery<T> Include<T>(this ObjectQuery<T> mainQuery, Expression<Func<T, object>> subSelector)
{
return mainQuery.Include(FuncToString(subSelector.Body));
}
private static string FuncToString(Expression selector)
{
switch (selector.NodeType)
{
case ExpressionType.MemberAccess:
return ((selector as MemberExpression).Member as Reflection.PropertyInfo).Name;
case ExpressionType.Call:
var method = selector as MethodCallExpression;
return FuncToString(method.Arguments[0]) + "." + FuncToString(method.Arguments[1]);
case ExpressionType.Quote:
return FuncToString(((selector as UnaryExpression).Operand as LambdaExpression).Body);
}
throw new InvalidOperationException();
}
public static K Include<T, K>(this EntityCollection<T> mainQuery, Expression<Func<T, object>> subSelector)
where T : EntityObject, IEntityWithRelationships
where K : class
{
return null;
}
public static K Include<T, K>(this T mainQuery, Expression<Func<T, object>> subSelector)
where T : EntityObject
where K : class
{
return null;
}
}
Посмотрите на следующие статьи:
http://www.thomaslevesque.com/2010/10/03/entity-framework-using-include-with-lambda-expressions/
http://msmvps.com/blogs/matthieu/archive/2008/06/06/entity-framework-include-with-func-next.aspx