Have you run into the need to handle a conversion in LINQ from a SQL that used CASE function?
Here is the usage example in the SQL Books Online:
SELECT ShipVia, CASE ShipVia
WHEN 1 THEN 'A.Datum'
WHEN 2 THEN 'Contoso'
WHEN 3 THEN 'Consolidated Messenger'
ELSE 'Unknown'
END
FROM Orders
In C# you can use the Conditional/Ternary operator and cause LINQ to generate the SQL Case function calls in its call. Here is the above example in LINQ:
from o in Orders
select new { ShipVia = o.ShipVia, ShipViaName =
o.ShipVia == 1 ? "A.Datum' :
o.ShipVia == 2 ? "Contoso" :
o.ShipVia == 3 ? "Consolidated Messenger" :
"Unknown" }
Works handy when you are in a pinch!