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 - 欢迎您:) –