views:

204

answers:

1

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 ?

A: 

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.

Doobi
No but i've also discovered that the poco's need to defined their relationships using IQueryable instead of that the T4 generates which is ICollection; do you think this would have much impact ?
John Kattenhorn