【发布时间】:2017-05-15 20:02:38
【问题描述】:
我想抽象我的 IQueryable 调用,以便我可以将 where 传递给函数:
类似:
public IQueryable<T> executeQuery<T>(T baseType, Expression<Func<T,object>> whereFunc) where T : class
{
//Get context
DataContext dbContext = new DataContext(connection);
//Get the table representation
Table<T> baseTable = dbContext.GetTable<T>();
//Get our query object
IQueryable<T> baseQuery = from item in baseTable where whereFunc select item;
}
上述方法不起作用,但有什么方法可以做到这一点吗? (即一般创建 IQueryable 但允许传入 where 子句?)
【问题讨论】:
标签: c# .net sql-server linq linq-to-sql