我有一个带有列的表OneStopPrice; MultiStopPrice; NonStopPrice
。我想拥有Min()
所有 3 列。但是如果Min()
任何一列是0,它必须被忽略。
OneStop | NonStop | MultiStop
-----------------------------
233.23 | 0.0 | 355.23
此处的 NonStop 必须被视为最高值以便忽略它。
有人对此有想法LinQ
吗?
我使用查询如下:
var data = odyResults.GroupBy(logEle => new { logEle.Air.FromCity, logEle.Air.ToCity }, (key, group) => new{
FromCity = key.FromCity,
ToCity = key.ToCity,
OneStopPrice = group.Min(x=>x.Air.OneStopPrice),
MultiStopPrice = group.Min(x => x.Air.MultiStopPrice),
NonStopPrice = group.Min(x => x.Air.NonStopPrice),
FromToCityCount = group.Count()
});