linq to sql lambda - 不在where条件下的语法

时间:2018-03-21 15:13:45

标签: c# linq lambda linq-to-sql

我想使用'!'在我的.Where中排除以下记录。

语法是什么?

// where do I put the ! to get the syntax correct
.Where(p => p.StartDate >= startDate && p.EndDate <= DateTime.Now.Date)

1 个答案:

答案 0 :(得分:1)

.Where(p => !(p.StartDate >= startDate && p.EndDate <= DateTime.Now.Date))

OR

.Where(p => p.StartDate < startDate || p.EndDate > DateTime.Now.Date)