在EntityFramework(和生成的LINQ)中有沒有一種方法可以針對未硬編碼的實體的屬性進行查詢?使用EF查詢編譯時未知屬性
比方說,可以用於搜索功能的東西。
public IList<Entity> Search (string propertyName, object value) {
// something that'll do the following
return context.Set<Entity>()
.Where(x => x.propertyName == value)
.ToList()
;
}
你最終爲此做了什麼?我發現自己需要同樣的東西。用於多字段搜索。我正在關注這個例子,我使用EF來代替DataTables,就像他們的例子。 http://demos.telerik.com/aspnet-ajax/controls/examples/integration/gridandcombo/defaultcs.aspx?product=grid – hardba11 2012-06-15 22:40:02