SELECT Total_s, Total_k,Total_name,
CASE Total_status
WHEN 'S' THEN Total_Total_s
WHEN 'M' THEN Total_Total_m
ELSE 'Unknown'
END AS ยอดเงิน
FROM b_total
var query = from x in dbContext.b_total
select new
{
Total_s = x.Total_s,
Total_name = x.Total_name,
result = (new string[] {"S", "M"}).Contains(Total_status) ? (x.Total_status == "S" ? Total_Total_s : Total_Total_m) : "Unknown"
};
var query = from x in dbContext.b_total
select new
{
Total_s = x.Total_s,
Total_name = x.Total_name,
result = (new string[] {"S", "M"}).Contains(Total_status) ? (x.Total_status == "S" ? Convert.ToInt32(x.Total_Total_s) : Convert.ToInt32(x.Total_Total_m)) : 0
};