在我的LINQ查询中检查null

在我的LINQ查询中检查null,linq,linq-to-sql,Linq,Linq To Sql,下午,, 如果下面的行为空,我似乎无法解决如何忽略 where ((double)t.twePrice >= priceFrom && (double)t.twePrice <= (priceTo)) 其中((double)t.twePrice>=priceFrom&&(double)t.twePrice=priceFrom&&(double)t.twePrice检查twePrice是否为空,例如: where (t.twePrice != null &&a

下午,, 如果下面的行为空,我似乎无法解决如何忽略

where ((double)t.twePrice >= priceFrom && (double)t.twePrice <= (priceTo))

其中((double)t.twePrice>=priceFrom&&(double)t.twePrice=priceFrom&&(double)t.twePrice检查twePrice是否为空,例如:

where (t.twePrice != null && (double)t.twePrice >= priceFrom && (double)t.twePrice <= (priceTo))

其中(t.twePrice!=null&&(double)t.twePrice>=priceFrom&(double)t.twePrice=priceFrom&(double)t.twePrice检查twePrice是否不为null,例如:

where (t.twePrice != null && (double)t.twePrice >= priceFrom && (double)t.twePrice <= (priceTo))

其中(t.twePrice!=null&&(double)t.twePrice>=priceFrom&&(double)t.twePrice=priceFrom&(double)t.twePrice也许以下内容就足够了:

where ((priceFrom == null || (double)t.twePrice >= priceFrom) && (priceTo == null || (double)t.twePrice <= priceTo))
其中((priceFrom==null | | |(double)t.twePrice>=priceFrom)和&(priceTo==null | | |(double)t.twePrice=priceFrom)

其中(priceTo==null | | |(double)t.twePrice以下可能就足够了:

where ((priceFrom == null || (double)t.twePrice >= priceFrom) && (priceTo == null || (double)t.twePrice <= priceTo))
其中((priceFrom==null | | |(double)t.twePrice>=priceFrom)和&(priceTo==null | | |(double)t.twePrice=priceFrom)

where(priceTo==null | | |(double)t.twePrice谢谢,但是这不起作用,我已经更新了我的问题,因为我刚刚注意到我遗漏了一些重要的细节!我的第二个陈述没有涵盖它吗?没有:(tweprice永远不会为空。只有priceFrom和priceTo可能是,因为它们被传递到QueryTank中,但这不起作用,我已经更新了我的问题,因为我刚刚注意到我遗漏了一些重要的细节!我的第二个声明是否没有涵盖它?否:(tweprice永远不会为空。只有priceFrom和priceTo在传递到查询时可能为空。您的意思是说“priceFrom”和“priceTo”可以为空,在这种情况下,您想忽略此查询吗?是的,它们可以为空,如果与其他选项一样,则需要忽略:)您的意思是说“priceFrom”和“priceTo”可以为空,在这种情况下,您希望忽略此查询?是的,它们可以为空,如果与其他选项一样,则需要忽略:)
where (priceFrom == null || (double)t.twePrice >= priceFrom) 
where (priceTo == null || (double)t.twePrice <= priceTo)