开发者

How should I expose database classes over web services?

Given that directly exposing linq to sql or entity framework classes over web services is a bad idea, how should I expose the data over a web service such as WCF?

It开发者_运维问答 seems like I would have to create a parallel set of classes for the web service, and then marshal the data into those, which doesn't seem very elegant.

The web services will be custom, so something like RIA is not very useful in this case.


You can use the support for POCO (Plain Old CLR Objects) in EF 4 to expose the entity model as simple objects. The designer supports converting entity data model into POCO objects.

Specifically for WCF service scenario, you could also use the self tracking entities T4 template available in EF 4 when you try to add new item to the project.

I hope following link will be helpful to you

http://blogs.msdn.com/b/efdesign/archive/2010/03/10/poco-template-code-generation-options.aspx

http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx

Generate POCO classes in different project to the project with Entity Framework model


Have you seen OData and WCF Data Services? Here is a great talk by ScottHa: http://www.hanselman.com/blog/ODataBasicsAtTheAZGroupsDayOfNETWithScottGu.aspx

OData, through WCF Data Services, works seamlessly with EF 4.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜