1. CASE WHEN ... THEN ...
var expr = from p in context.Products select new { 商品ID = p.ProductID, 商品名称 = p.ProductName, 是否库存 = p.UnitsInStock > 0 ? "是" : "否" };
SELECT [Extent1].[ProductID] AS [ProductID], [Extent1].[ProductName] AS [ProductName], CASE WHEN ([Extent1].[UnitsInStock] > 0) THEN N‘是‘ ELSE N‘否‘ END AS [C1] FROM [dbo].[Product] AS [Extent1]
时间: 2024-10-20 05:38:26