比较两个对象图并获得差异 [英] Compare Two Object Graphs and Get Differences

查看:73
本文介绍了比较两个对象图并获得差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我拥有的系统构建BAM仪表板,但我想知道从工作流系统中提取的每个刻度之间的差异。  目前,我正在拉动一个IEnumerable< T>从数据库中获取
每10秒钟在我的系统工作流程中的项目列表。 

I'm trying to build a BAM dashboard for a system that I have, but I want to know the differences between each tick that I pull from the workflow system.   Currently, I'm pulling an IEnumerable<T> from a database to get a list of items that are in the workflow of my system every 10 seconds. 

from documents in Observable.Interval(TimeSpan.FromSeconds(10)).Select(_ => getRootItems(cancel))

在此之后,我想我已经尝试了几乎所有我能想到的缓冲区组合......  理想情况下,我想得到这样的结果:

After this, I think I've tried almost every combination of Buffer that I could think of...   Ideally, I'd like to get something like this:

select
                    new
                        {
                            (Elements of document in workflow - defining later) Key,
                            rootitem Current,  // Can this be null if the item isn't in workflow anymore?
                            rootitem Previous, // Can this be null if it wasn't seen before?
                            bool Clanged
                        }

如果有人可以通过网络向我发送关于如何做到这一点的好教程,我真的很感激。  ;&NBSP;我很乐意使用LINQ来做这件事,但如果Rx可以轻松地为我做这件事,我不想自己跟踪所有这些对象。

If anyone can pass me on to a good tutorial online on how to do this, I'd really appreciate it.   I'd love to do this using LINQ, but I'd hate to keep track of all these objects myself if Rx can easily do it for me.

谢谢

推荐答案

看起来你想要使用Zip操作符应用于源的旧技巧然后"跳过(1)"来源的副本。

It looks like you want to use the old trick of applying the Zip operator to a source and then a "Skip(1)" copy of the source.

例如。

documents.Zip(documents.Skip(1), (previous, current)=>new {??, previous, current, previous.Equals(current)})

可能会想要发布文档序列,所以你不会最终订阅两次并且有两个序列轮询数据库。

would will probably want to Publish the documents sequence so you dont end up subscribing twice and having two sequences polling the DB.

如果您正在寻找Rx教程,那么我希望我的网站
IntroToRx.com
解决您的问题。它涵盖了Zip& amp;发布并且应该引导您完成所有您需要了解的内容以便使用Rx。

If you are looking for an Rx Tutorial then I hope that my website IntroToRx.com solves your problem. It covers both Zip & Publish and should walk you through all that you need to know to get up to scratch with Rx.

HTH

Lee Campbell

Lee Campbell


这篇关于比较两个对象图并获得差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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