在我的数据库中,我有 13 个订单。
下面的代码返回所有这些,如果OrderID = 0
and CustomerName = "lorem"
。
如果我评论该行(OrderID == 0) ?....
,它可以正常工作。怎么了 ?
var result = (from x in db.Order
where
(OrderID == 0) ? x.OrderID > 0 : x.OrderID == OrderID
&&
(string.IsNullOrEmpty(CustomerName)) ?
!string.IsNullOrEmpty(CustomerName)
:
x.User.Name.Contains(CustomerName)
select x)
.ToList();