我有两个 Guid 集合:
List<Guid> statuses;
List<Guid> priorities;
如何进行以下查询:
var result = context.Activity.Where(a =>
(a.StatusID == statuses[0] || a.StatusID == statuses[1] || ... || a.StatusID == statuses[n]) &&
(a.PriorityID == priorities[0] || a.PriorityID == priorities[1] || ... || a.PriorityID == priorities[m]))
集合可能是空的,在这种情况下,我们不应该添加适当的“与”条件。如何做这样的动态查询?
更新
嗯,想象一下我需要这样的东西:
List<Func<Activity, bool>> conds = new List<Func<Activity, bool>>();
var result = context.Activity.Where(conds[0] || (conds[1] && conds[2]))
怎么做?