我有一个linq行,如果DiffDays> 3,它将被包括在内。但是我有另一个条件,如果ID不存在于另一个表中,它将被包括在内。
我试过使用下面的代码,但它不起作用:
var stock = (from x in db.Stock
where (!(from re in db.Reserve select re.StockID).ToList().Contains(x.StockID))
|| DbFunctions.DiffDays(DateTime.Now, y.DateReserved) > 3
select x);正确的做法是什么?
发布于 2017-09-23 17:23:53
您可以像这样使用Any:
(from x in db.Stock
where !db.Reserve.Any(re => re.StockID == x.StockID)
|| DbFunctions.DiffDays(DateTime.Now, y.DateReserved) > 3
select x);https://stackoverflow.com/questions/46377999
复制相似问题