Web 服务数据源的 ORM?
似乎有很多很棒的对象关系映射器 - 其中有几个是我自己使用过的(LLBLGen 是我非常喜欢的一个)。当数据源不是数据库时,或者更具体地说,当数据源是多个、高度粒度的、返回大量域特定对象和 DTO 的 Web 服务时,有谁知道有哪些 .Net 工具可以帮助构建丰富的数据访问层?
您可能会问,当我有可以直接从 BLL 调用的 Web 服务时,为什么我还需要数据访问层?好吧,除了日志记录、缓存和预取机制之外,我希望能够将所有略有不同的 Web 服务 DTO 转换为具有细微不同的命名约定,并将它们映射到我自己的、一致命名和构造的类,并具有共同的基础类型。这不是一项小任务,所以我希望有一些工具可以提供帮助!
感谢您的任何建议或指点!
There seems to be lots of great Object Relational Mappers out there - several of which I have used myself (LLBLGen being one I like a lot). Does anyone know of any .Net tools out there to help build a rich Data Access layer when the DataSource is not a database - or more specifically, where the datasource is multiple, highly granular, webservices that return lots of Domain Specific objects and DTOs?
Why do I even want a Data Access layer when I have webservices I could just call directly from the BLL you may ask? Well, logging, caching, and pre-fetching mechanisms aside, I would like to be able to translate all the slightly varying webservice DTOs with subtly different naming conventions, and map them to my own, consistently named and constructed classes, with a common base type. No small task, so I am hoping there are some tools out there to help!
Thanks for any advice or pointers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
从技术上讲,您需要的不是 ORM,因为没有“关系”部分。因此,现有的类似 ORM 的工具很可能不适合开箱即用。
我建议您查看自定义代码生成工具,例如 T4(VS2008+ 中内置)或 CodeSmith。
SubSonic 3 有一些 ActiveRecord 和存储库类的模板,您可以从这些模板开始,并将它们更改为使用 Web 服务作为“后端”而不是数据库。
PS仅供参考,这里是一个讨论 ORM 和类自动生成的线程(由我前段时间发起)。
Techinically, what you need is not an ORM, as there is no "relational" part. So, most likely, existing ORM-like tools won't suit out-of-the-box.
I'd suggest you to look at the custom code generation tools, for instance, T4 (builtin in VS2008+) or CodeSmith.
SubSonic 3 has some templates for ActiveRecord and repository classes, you could start with those templates, and change them to use web services as the "backend" instead of the database.
P.S. Just for the reference, here is one thread (started by me some time ago) that discusses ORMs and class auto-generation.
你所描述的不是一个 ORM,所以你可能不会以这种方式找到你想要的东西。
如果主要目标是在服务引用的对象模型和您自己的对象模型之间进行转换,请查看 AutoMapper。它旨在自动执行此类任务。
What you're describing isn't an ORM, so you probably won't find what you're after that way.
If the primary goal is to translate between a service reference's object model and your own, look at AutoMapper. It's designed to automate exactly that type of task.
根据场景的实际复杂程度,我会针对您提到的功能(缓存、日志记录等)和 AutoMapper 使用更具体的框架来推出自己的框架。
附:虽然可能有一些框架可以满足您的需求,但当时我没有想到。
Depending on how complex the scenario really is, I'd roll my own using more specific frameworks for the features you mentioned (caching, logging, etc.) and AutoMapper.
ps. while there might be frameworks that do what you need, none come to my mind at the time.
也许我遗漏了一些东西,但是您不能只使用 Web 服务的 WSDL 文件来生成该服务的客户端代理代码吗?
Maybe I am missing something, but can't you just use the web service's WSDL files to generate your client side proxy code for the service.