简体   繁体   English

使用SOA(Microsoft CRM)从2层NHibernate迁移到3层的推荐方法是什么?

[英]What are recommended approaches for migrating from 2-tier NHibernate to 3-tier with SOA (Microsoft CRM)?

Given a (current) project that implements a 2-tier architecture with a well-separated on-tier business layer following the typical generic DAO architecture as pioneered by Bill McCafferty on CodeProject and explained briefly in chapter 10 of NHibernate in Action. 给定一个(当前的)项目,该项目采用由Bill McCafferty在CodeProject上提出并在NHibernate in Action的第10章中进行了简要介绍的典型的通用DAO体系结构 ,实现了一个具有分离的层级业务层的2层体系结构。

This project must be moved to do CRUD operations and business logic through Microsoft CRM as middle tier using web services. 必须将该项目移动为通过Microsoft CRM作为使用Web服务的中间层来执行CRUD操作和业务逻辑。 Custom objects and methods are defined in the CRM to mimic the current situation. CRM中定义了自定义对象和方法,以模仿当前情况。

I don't think it's a good idea to start moving the POCO's back and forth the same way we used to do. 我认为以以前的方式来回移动POCO并不是一个好主意。 Also, features as lazy loading, caching and concurrency all have to be treated differently. 另外,必须对延迟加载,缓存和并发等功能进行不同的处理。 Considering that we have to minimize calls between middle-tier en presentation layer bring around another challenge. 考虑到我们必须最小化中间层en表示层之间的调用带来了另一个挑战。

Implementing DTO's seems the right cause of action, but requires a long path (plus a learning path for the team). 实施DTO似乎是正确的行动原因,但需要很长的路(以及团队的学习路径)。 I've done SOA projects before, but now I'm looking for the path of least resistance. 我以前做过SOA项目,但是现在我正在寻找阻力最小的途径。 Can we continue to use NHibernate, even if direct DB connection will not be an option? 即使不能选择直接DB连接,我们是否可以继续使用NHibernate? Will we have to rethink the design, or are disconnected entities, introduced in .NET 4.0 perhaps an option? 我们是否需要重新考虑设计,或者是.NET 4.0中引入的实体断开连接? How painless can it become? 它会变得多么无痛?

Take a look at MS CRM SDK 4.0.12, in Reflector too. 看看Reflector中的MS CRM SDK 4.0.12。 They went quite a long way to a proper ORM there, CRUD and Linq including. 他们为建立适当的ORM(包括CRUD和Linq)做了很长的路要走。 There are many subtle (and not-so-subtle) differences with NH there, and it isn't yet plugin-trained, but at least you can borrow some ideas. NH与NH有许多细微(但不是那么细微)的区别,并且尚未经过插件培训,但是至少您可以借鉴一些想法。

We use XRMLinq - http://www.xrmlinq.com . 我们使用XRMLinq- http: //www.xrmlinq.com。 It builds your DTO objects and you can then use LINQ syntax to query against them. 它会构建您的DTO对象,然后您可以使用LINQ语法对其进行查询。 The framework automatically converts your LINQ queries to FetchXML queries against the CRM webservices. 该框架针对CRM Web服务自动将LINQ查询转换为FetchXML查询。 The DTO objects are created as partial classes, so you can add your own logic that will survive regenerations. DTO对象创建为部分类,因此您可以添加自己的逻辑,这些逻辑将在重新生成后继续存在。

Another tip: use custom workflow activities for your business logic where possible. 另一个技巧:在业务逻辑中尽可能使用自定义工作流活动。 Instead of writing logic directly into the DTO that XRMLinq generates, consider creating a custom workflow activity that will fire when certain fields are updated. 与其直接将逻辑写入XRMLinq生成的DTO中,不如考虑创建一个自定义工作流活动,该活动将在更新某些字段时触发。 This forces your business logic to run even if those fields get updated somewhere else in the system (not through your custom DTO logic). 即使这些字段在系统中的其他位置得到更新,这也将迫使您的业务逻辑运行(而不是通过自定义DTO逻辑)。 It also gives you a nice queueing system and failback mechanism - if your custom workflow activity throws an exception, the workflow is "paused" until you fix the problem, at which point you can just resume the workflows that failed. 它还为您提供了一个很好的排队系统和故障回复机制-如果您的自定义工作流程活动引发异常,则该工作流程将被“暂停”,直到您解决问题为止,此时您可以恢复失败的工作流程。 This only works for business logic that can be run asynchronously obviously, but for synchronous logic I would still recommend looking at custom plugins before writing logic into the DTO. 这仅适用于显然可以异步运行的业务逻辑,但是对于同步逻辑,我仍然建议在将逻辑写入DTO之前先查看自定义插件。

Hope that helps! 希望有帮助!

Here are some good articles that detail a SOA architecture that has been trailed on projects of all sizes, the series is still been written, I believe it will be of use to you. 这里有一些很好的文章,详细介绍了已在各种规模的项目中使用的SOA架构,该系列仍在编写中,我相信它将对您有用。

http://hubpages.com/hub/Building-Service-Orientated-Architecture http://hubpages.com/hub/Building-Service-Orientated-Architecture

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM