0
如何使用LINQ編寫此查詢?將SQL查詢轉換爲LINQ to SQL查詢
SELECT CAST(CASE WHEN [IsForReplication] = 1 THEN 'Yes'
ELSE 'No' END AS NCHAR) as [IsForReplication], *
FROM [SAN].[dbo].[PolicyInterval]
如何使用LINQ編寫此查詢?將SQL查詢轉換爲LINQ to SQL查詢
SELECT CAST(CASE WHEN [IsForReplication] = 1 THEN 'Yes'
ELSE 'No' END AS NCHAR) as [IsForReplication], *
FROM [SAN].[dbo].[PolicyInterval]
var query = from pi in context.PolicyInterval
let IsForReplication = pi.IsForReplication ? "Yes" : "No"
select new
{
IsForReplication,
PolicyInterval = pi,
};
var result = PolicyInterval.Select(entry => new {IsForReplication = entry.IsForReplication.Equals(1).ToString(), data = entry});