Expression<Func<Order_info, bool>> expre = expression;
var q = db.order_info;
IQueryable<Order_info> query = q;
if (expre != null)
{
query = query.Where(expre);
}
修改为:
1 Expression<Func<Order_info, bool>> expre = expression; 2 var q = db.order_info; 3 IQueryable<Order_info> query = q; 4 if (expre != null) 5 { 6 //query = query.Where(expre); 7 query = query.Where(expre.Compile()).AsQueryable(); 8 }
因为query.Where(expre)返回的是 IEnumerable<Order_info>类型的