1
使用VS 2013(不是C#6.0還)嵌套條件運算
我有以下的LINQ其工作原理:
var radData = (from stop in dbContext.stop_details
join del in dbContext.stop_event on stop.id equals del.stop_id into Inners
from sd in Inners.DefaultIfEmpty()
where stop.ship_date == startDate && stop.cust_ref_5_terminalID == "HEND"
select new
{
shipDate = stop.ship_date,
custRef = stop.cust_ref_5_terminalID,
name = stop.customer.customer_name,
ontime = (int?)sd.ontime_performance,
OTP = ((int?)sd.ontime_performance) < 1 ? "Ontime" : "Late"
}).ToList();
但OTP
需求價值爲以下取決於ontime_performance
:
- 空 - 「打開」
- < 1 「龍泰」
- 1 「晚一天」
- 2 「兩天遲到」
- 「> 2 「的三個或更多日晚」
有沒有辦法窩呢?到目前爲止,我沒有嘗試過任何工作..
謝謝。
完美 - 感謝額外的價值部分。 <1需要保留,因爲還有負值返回。很好的答案。 –
@MostlyLucid - 歡迎您:) –