类型化数据集和 Dtos
我有一个连接到 WCF 服务以实现其业务逻辑的 Web 应用程序。 出于性能和互操作性的原因,我想使用简单的 Dto 在 WCF 边界传输数据。
但是,我必须使用类型化数据集进行数据访问(由于政治原因,ORM 或任何其他选项不可用)。
将 Dto 与类型化数据集一起使用是个好主意吗? 有人这样做过吗? 有推荐的模式吗? 最重要的是,是否有一个库/工具/方法可以从类型化数据集中自动生成 Dto?
I have a web application that connects to WCF services for its business logic. I would like to use simple Dto's for transfering data at the WCF boundary for performance and interoperability reasons.
However I have to use typed datasets for data access (ORM or any other option is not available due to political reasons).
Is it a good idea to use Dto's along with typed datasets. Have anyone done this? Is there a recommended pattern? And most importantly is there a library/tool/method to auto generate Dto's from the typed datasets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我想到了实体翻译模式。
http://msdn.microsoft.com/en-us/library/cc304747.aspx
好吧,也许是它的一个变体。
我最近必须做一些类似的事情,我刚刚创建了另一个“层”,它将存储在数据行/数据表等中的数据转换为数据契约对象。 服务层可以使用数据访问方法的结果作为参数来调用这个新的层方法。
这是一个快速而肮脏的 PSUEDOCODE 示例:
SERVICELAYER Class
Entity translation pattern comes to mind.
http://msdn.microsoft.com/en-us/library/cc304747.aspx
Well, maybe a variation on it.
I had to do something similiar recently, and I just created a another "layer" that translates the data stored in the datarow/datatable etc. into the data contract object. The service layer can call this new layer method with the results from your data-access method as a parameter.
Here's a quick and dirty PSUEDOCODE example:
SERVICELAYER Class
我建议使用类型化的 DataRow-s、DataTable-s。 类型化 DataRow 和 Dto 对象之间实际上没有太大区别。
就性能而言,您必须测试普通 Dto-s 是否会有所帮助(我对此表示怀疑)。
至于互操作性,类型化 DataRow-s 是普通类,因此它们与 Dto 对象一样具有互操作性。
I would suggest to use typed DataRow-s, DataTable-s. There's really not much difference between a typed DataRow and a Dto object.
Performance wise you have to test it that plain Dto-s will help (I doubt it).
As for interoperability, typed DataRow-s are plain classes, so they are as interoperable as Dto objects.