WCF Data Services consuming data from EF based repository
- by John Kattenhorn
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 ?