在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