在下面,model.Status 和 model.Source 值可能为空,也可能不为空。如果为 null,我希望表达式提取所有状态/来源。这对 lambda 是否可行,因为下面的语句不起作用?
var leads = db.CallCenterLead.Include("Profile").Include("Account")
.Where(x => x.DateSent >= model.DateFrom && x.DateSent <= model.DateTo
&& ((model.Status != null && x.Status == model.Status) || (model.Status == null))
&& (model.Source != null && x.Source == model.Source)).OrderByDescending(x => x.DateSent).ToList();