1
考慮下面的SQL查詢:CASE在WHERE子句相當於
SELECT
*
FROM
Orders
WHERE
(AdjShipDate IS NOT NULL OR EstShipDate IS NOT NULL)
AND
CASE
WHEN AdjShipDate IS NOT NULL THEN AdjShipDate
WHEN AdjShipDate IS NULL AND EstShipDate IS NOT NULL THEN EstShipDate
END
BETWEEN '2011-07-01' AND '2011-07-30'
的情況下,這時候表達依賴於從我試圖查詢表中的值(AdjShipDate)。我如何在Linq to SQL中編寫類似的查詢?
+1和LINES to SQL支持COALESCE。只有一件事 - 你應該爲where語句添加'(o.AdjShipDate!= null || o.EstShipDate!= null)'。 –
null-coalescing運算符在Linq-to-SQL中工作!謝謝! – Kerby