现在我试图创建一个泛型方法来将外键包含在我的资源库中。创建通用扩展方法时的问题
我目前得到了什么是这样的:
public static class ExtensionMethods
{
private static IQueryable<T> IncludeProperties<T>(this DbSet<T> set, params Expression<Func<T, object>>[] includeProperties)
{
IQueryable<T> queryable = set;
foreach (var includeProperty in includeProperties)
{
queryable = queryable.Include(includeProperty);
}
return queryable;
}
}
但是当编译我的错误:
The type 'T' must be a reference type in order to use it as parameter 'TEntity' in the generic type or method 'System.Data.Entity.DbSet'
可能是什么问题吗?
啊我现在看到了。非常感谢你的帮助! – JensOlsen112 2014-10-10 20:48:55