Consider the following SQL query:
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'
The case’s WHEN expressions depend on a value (AdjShipDate) from the table that I’m trying to query. How would I write a similar query in Linq to SQL?
It’s essentially a COALESCE:
Though I’m not certain in the ?? operator is supported by Linq-to-SQL. If it doesn’t you could try