我想使用包括一些选择这样的关键字:包括与扩展方法关键字不提供过滤
context.Categories.Include(c => c.Products)
我已经搜索互联网上,发现下面的方法:
public static class ObjectQueryExtension
{
public static ObjectQuery<T> Include<T>(this ObjectQuery<T> mainQuery,Expression<Func<T, object>> subSelector)
{
return mainQuery.Include(((subSelector.Body as MemberExpression).Member as System.Reflection.PropertyInfo).Name);
}
}
当我有复制粘贴这个方法在我的项目,当我打字
context.category.include()//
那么它只是显示我用字符串作为像参数:
context.category.include("");//like this
我想使用包括关键字像这样:
context.Categories.Include(c => c.Products)
任何机构可以TEMM我什么问题???
只需添加“使用EntityFramework;”你的班级 – ErikEJ 2014-10-10 07:36:40