我是 LINQ 的新手,上面的代码对我来说执行得很好。
但我不明白为什么在最后一句中写的是 c.payload.Quantity 而不是 c.Quantity。
当我用谷歌搜索时,我知道值 Quantity 是从我们从 c 中的结果中获得的有效负载中获得的,这是否意味着有效负载是 filterQuery 的最终输出?
var orderData = new[]
{
new {OrderDate = new DateTime(2011,1,1,8,30,00), ItemID = "100", UnitPrice = 0.99, Quantity =5},
new {OrderDate = new DateTime(2011,1,1,8,31,00), ItemID = "200", UnitPrice = 3.99, Quantity =2},
new {OrderDate = new DateTime(2011,1,1,9,02,00), ItemID = "200", UnitPrice = 1.50, Quantity =1},
new {OrderDate = new DateTime(2011,1,1,9,07,00), ItemID = "100", UnitPrice = 4.10, Quantity =3}
};
var orders = orderData.ToPointStream(Application,ev=>PointEvent.CreateInsert(ev.OrderDate,ev),AdvanceTimeSettings.StrictlyIncreasingStartTime);
var filterQuery = from o in orders where o.Quantity>=2 select o;
(from o in filterQuery.ToIntervalEnumerable() where o.EventKind == EventKind.Insert
select new {o.StartTime,o.EndTime,o.Payload.Quantity}).Dump("Heading");