【发布时间】:2010-01-19 22:11:05
【问题描述】:
我在使用 linq-to-sql 时遇到了一个相当奇怪的问题。在下面的例子中,
var survey = (from s in dbContext.crmc_Surveys
where (s.crmc_Retail_Trade_Id == tradeId) && (s.State_.Equals(state))
select s).First();
如果tradeId 为null,它的行为就好像我专门指定了这样的null,
var survey = (from s in dbContext.crmc_Surveys
where (s.crmc_Retail_Trade_Id == null) && (s.State_.Equals(state))
select s).First();
这是我想要的行为。事实上,除非两个值都不为空,否则它不会返回任何内容。我不知道如何在缺少几个不同的 linq 查询的情况下完成这个任务。有什么想法吗?
【问题讨论】:
标签: c# .net linq linq-to-sql