Returning EF entities using WCF - Read only web service / public API
I'm currently migrating an application from Linq-to-SQL & ASP.net Web Services (asmx) to Entity Framework and WCF.
My question is, I have a bunch of POCO classes which i have xml mapping files for (for the linq to sql) I've replaced my linq to sql with an entity framework data model
I've got an interface - something like IService - that has all the methods on it that i need my service to implement - for example:
Product[] GetProductsByKeyword(string keyword);
In the above case, Product is a POCO. I now have them as entities within my ef data model - i'm using .net 4, and could take advantage of poco support, but don't really see the need - This service is strictly read only.
What's the best way of returning entities in my WCF service? I want i开发者_运维知识库t to support other client platforms, not just .net (so php guys could use it)
Use OData. It's extremely simple when you already have an entity model. Here's an example with a schema which may look familiar.
Then you can use PHP just as easily. And lots of other languages and frameworks, too.
精彩评论