We have an existing repository which is based on EF4 / POCO and is working well. We want to add a service layer using WCF Data Services and looking for some best practice advice.
So far we have developed a class which has a IQueryable property and the getter triggers the repository 'get all users' method. The problem so far have been two-fold:
1) It required us to decorate the ID field of the poco object to tell data service what field was the id. This now means that our POCO object is not 'pure'.
2) It cannot figure out the relationships between the objects (which is obvious i guess).
I've now stopped this approach and i'm thinking that maybe we should expose the OBjectContext from the repository and use more 'automatic' functionality of EF.
Has anybody got any advice or examples of using the repository pattern with WCF Data Services ?
I guess it's a matter of being pragmatic. Does decorating the POCO break anything else? If not, perhaps it's the best way to do it.
WCF Data Services and oData are pretty new, I've also been looking for guidance and it seems a bit thin.
Can you expand a bit more on what you want to expose, and who'll be using it?
The issues I've seen so far in our project
A couple of traps....
If it's Flash / Flex based you will probably have issues with Flash / Flex not being able to use HTTP PUT/MERGE or DELETE. You get around this by using x-httpmethod-override
If it's javascript / jquery, make sure you turn on json
Overall, I really like it, a super fast way to expose an API, and provided you don't have heavy business logic, it works well.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.