我想动态构建我的 where 条件列表。这是我的代码片段:
protected Expression<Func<event_info, bool>> _wherePredicate = c => true;
public void main()
{
_wherePredicate = _wherePredicate.And(c => c.createdby == 6);
_wherePredicate = _wherePredicate.And(c => c.isdeleted == 0);
var query = from ev in dataConnection.event_info
where ev.isdeleted == 0
select ev;
Results = query.Where(_wherePredicate).ToList();
}
除非这不起作用,因为 linq-to-entities 不支持 Invoke 方法。
我可以在 linq-to-entities 中组合谓词的好方法是什么?