实体框架POCO与WCF软件设计问题 [英] Entity Framework POCO with WCF software design question

查看:138
本文介绍了实体框架POCO与WCF软件设计问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将在我的应用程序中使用Entity Framework和WCF。正如我所看到的那样,建议的做法是使用POCO与Entity Framework,并将POCO类用作DataContracts。这实际上是POCO和Attributes使用的,因为我没有错。



但是我被要求为Entity Framework POCO和WCF DataContracts使用单独的类。并使用POCO和DataContracts之间的映射器。喜欢, Foo FooContract 具有相同的属性。



我处于第一个方面,但我想知道第二种方法(单独的类方法)是否为应用程序提供了灵活性,或者只是浪费了努力。



我将如果您能分享您对POCO和DataContracts使用单独类的想法和经验,那么请参考以上的优缺点。

解决方案

为您的POCO和您的合同分开的课程将允许您创建面向消息的服务,而不是RPC样式服务。



拥有面向消息的服务将使您的服务更加灵活,做更多的工作,并减少与每个服务使用的对象的束缚。



基于消息的服务也更符合面向服务架构的精神。您可以在维基百科中阅读有关面向消息的服务。



我还建议您选择面向服务的架构:概念,技术与如果您对良好服务设计背后的原则感兴趣,请由Thomas Erl设计。


I am going to use Entity Framework and WCF in my application. The suggested practice, as I saw, is using POCO with Entity Framework and also using POCO classes as DataContracts. That is actually what POCO and Attributes are used for, -if I am not wrong.

However I am asked to use seperate classses for Entity Framework POCO's and WCF DataContracts. And to use a mapper between POCO's and DataContracts. Like, Foo and FooContract with same properties.

I am on the first approachs side but I wonder if the second approach (seperate classes approach) provides flexibility to the application or is it just a waste of effort.

I will be grateful if you can share your thoughts and experiences about using seperate classes for POCO and DataContracts, pros and cons about that.

解决方案

Having separate classes for your POCOs and your Contracts will allow you to create Message Oriented services rather than RPC Style services.

Having Message Oriented services will allow your services to be more flexible, do more work, and be less tied to the objects that each service uses.

Message Based services also fall more in line with the spirit of Service Oriented Architectures. You can read more about Message Oriented services at Wikipedia.

I would also suggest picking up Service-Oriented Architecture: Concepts, Technology & Design by Thomas Erl if you are interested in the principles behind good service design.

这篇关于实体框架POCO与WCF软件设计问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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