0
我想創建一個過濾器來搜索基本查詢上的一個或多個列。它的工作原理,問題是,我100%確定這是不是最佳的,因爲查詢是呈現和搜索通過代碼(而不是MSSQL)執行linq實體表達式樹在匿名類型的地方
所以我的問題是:我可以通過表達式樹(不熟悉它),所以查詢生成的數據庫端?
p.s:我不想使用動態LINQ
謝謝!
var basequery = (from x in db.table1
join x1 in db.table2 on x.id equals x1.someid
where x.deleted != null && x.moreCondition = "blah"
select new {
x.field1,
x.fiedl2
x2.field1,
x2.field3
});
適用於基本查詢過濾器來搜索每列:
foreach (var item in Columns)
{
basequery = basequery.AsEnumerable()
.Where(i => (i.GetType().GetProperty(item.Data)
.GetValue(i, null) ?? string.Empty).ToString().ToUpper().Contains(item.Search.Value.ToUpper())).AsQueryable();
}
這是我需要:[http://stackoverflow.com/questions/931444/trying-to-develop-a-new-extension-method](http://stackoverflow.com/questions/931444/trying-to-發展 - 一個全新的擴展方法) – Zulander