Context: Repository-pattern, WCF, WPF/SL
In my Repository of self-tracking Entities i need to explicitly load some related properties in order to correctly process the query. Those are not the includes requested by the client and i would like to get rid of them in order to keep network traffic resonable. My solution so far is this:
- Receive Query
- Load includes necessary to answer request
- Execute Query
- Create temporary IEnumerable
- Iterate 4) and load all items again, this time with the include-path requested from the client-app only
- return entities via WCF
I would like to do this:
Receive Query
Load all includes (infrastructure plus client-requested)
Execute Query
Unload "Infrastructure" includes
return entities via WCF
What is the proper way to do this?
Thanks, Armin
How about lazy loading and proper DTO response objects ?
Result : only the corresponding properties inside Contracts.Order are loaded:
Ex. Contracts.Order Number OrderDetails (=> Only this property is loaded through lazy loading because it is mapped)
If you are building a SOA or webservice, don't let the client specify load graphs. If it's necessary for the client to specify load graphs consider deploying the Model using WCF Data Services, works great.
Perhaps you could build two systems .. one SOA and one (readonly) Data Service.