开发者

Combining business object & data transfer object into one. Would it work?

I know data transfer objects are used for transferring data only and having lightweight objects over the wire.

If I have tens or hundreds of business objects, creating dto's and mappers seems like a lot of work.

What about 开发者_开发知识库creating a super/hybrid object which does validation and business rules AND used for transferring data. For example, for properties which are used for data transfer, decorate these with [DataMember] (for WCF). Does this mean only these properties get transferred? Would this work and what are the drawbacks?


It is possible and will have no problems, if your business objects are POCO (plain old C# objects) and doesn't hold references to server-side object.

Also if you use some ORM you may have problem operating (saving, reloading etc.) entities detached from context (eg received as parameters in services), and you may need some tricks like attaching it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜