聚合和测量 [英] Aggregation and Mearging

查看:92
本文介绍了聚合和测量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述







$
我有一个基于MVVM框架的WPF应用程序需要在时间线图表上显示

汇总值。在业务层持续收到数据b
,用于在某些用户可选择的属性(如年/月/日)上汇总(实时)。这个聚合的

集合最终将绑定到时间轴视图。我不想在每次数据合并时重新创建

聚合的viewmodel集合。任何新数据应该在现有的集合中合并到适当的位置。例如,如果收集按年分组并且收到2012年b
的新记录,则为
,然后2012年的计数应自动递增$
1.  有没有办法使用被动扩展来实现这个目标?



这是代码片段....




< span style =""> 应用程序业务层有一个modelList集合,它接收  continuous < span style ="font-size:11pt"> 有关从WCF服务购买的车辆的数据。这个
的数据在购买日期 汇总到另一个名为的集合中  列表1。因此,聚合集合(list1)具有为每个日期购买的车辆的数量。以下
代码用于汇总



 



             var   list1 = modelList.GroupBy((x)=> x.PurchaseDate)。选择((y)=>  new   < span style ="color:#2b91af"> DateVehicleCountViewModel ()
{Date = y.Key,Count = y.Count()})。ToList();



我们无法确定更新  特定  日期list1当新记录是&bbsp; modelList 中添加
时(对于新日期或现有日期)。一些 
可能的方法可以是:




1)处理modeList的collectionchanged事件。将新项目分组并合并到原始集合(list1)。即我们想以这样的方式合并这两个列表:如果list1中存在相同的日期,那么count将从list2添加到list1&的相同项目中。
如果list1中不存在日期,则新项目将插入list1中。实现这个的语法应该是什么?

$
2)我们可以使用类似于CreateDerivedCollection的东西但是它会作用于永无止境的列表吗?






任何帮助或  指南  非常高 赞赏



问候,




-Sanjeev Sharma



解决方案

请帮助!!!





Hi,



I have a MVVM framework based WPF application which needs to display
aggregated values over a timeline chart. Data is being continuously received
at the Business layer which is to be aggregated (in realtime) on some
user selectable attribute like year/ month/ day. This aggregated
collection will finally bind to the timeline view. I do not want to recreate the
aggregated viewmodel collection on every data merge. Any new data should
be merged in the existing collection at its proper place. For example,
if the collection is grouped on year and a new record is received for
year 2012, then count for 2012 should be automatically incremented by
1.   Is there any way achieving this using reactive extension?

Here is the code snippet....

Application business layer has a modelList collection which receives continuous data about vehicle purchased from a WCF service. This data is aggregated on purchase date into another collection called list1. Thus the  aggregated collection (list1) has count of vehicle purchased for each date. Following code is used for aggregation

 

            var list1 = modelList.GroupBy((x) => x.PurchaseDate).Select((y) => new DateVehicleCountViewModel() { Date = y.Key, Count = y.Count() }).ToList();

We are not able to figure out the exact mechanism to update the aggregated count for a particular date in list1 when new records are added in  modelList  (for a new date or existing date). Some of the possible approaches  can be:

1) Handle the collectionchanged event of modeList. Group the new items and merge into original collection (list1). i.e. we want to merge these two lists in such way that if same date exists in list1 then count will add from list2 to the same item of list1 & if date doesn’t exist in list1 then new item get inserted in list1. What should be the syntax for achieving this?

2) Can we use something similar to CreateDerivedCollection but which acts on never ending list?

Any help or guidance is highly appreciated.

Regards,


-Sanjeev Sharma

解决方案

Help please !!!



这篇关于聚合和测量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆