如何使用LINQ编写此查询?
SELECT CAST(CASE WHEN [IsForReplication] = 1 THEN 'Yes'
ELSE 'No' END AS NCHAR) as [IsForReplication], *
FROM [SAN].[dbo].[PolicyInterval]
答案 0 :(得分:2)
var query = from pi in context.PolicyInterval
let IsForReplication = pi.IsForReplication ? "Yes" : "No"
select new
{
IsForReplication,
PolicyInterval = pi,
};
答案 1 :(得分:0)
var result = PolicyInterval.Select(entry => new {IsForReplication = entry.IsForReplication.Equals(1).ToString(), data = entry});