Lazy Downloading with WCF Domain Model?

I want to push my domain model to the WCF API and would like to get some thoughts on lazy loading methods with this type of setup.

Any suggestions on using this approach?


when I implemented this technique and enter my application, before the server returns my list, it gets to receive each property, which should be lazy loaded ... Thus, furious loading. Could you explain this problem or propose a solution?

Edit: appears , you can use the XMLIgnore attribute so that it is not visible during serialization .. still read about it though

+6
web-services wcf domain-driven-design
source share
3 answers

As for any remoting architecture, you can not load the complete graph of objects β€œdown the wire” in an uncontrolled way (unless you have a trivially small number of objects).

The Wikipedia article contains standard methods that are largely generalized (and in C # too!). I used both ghosts and cost holders, and they work very well.

To implement this technique, make sure you strictly separate it. On the server, the implementation classes of your service contract should be the only bits of code that work with data contracts. On the client, the level of access to the service should be the only code that works with the proxy.

This bundle allows you to customize the way the service is implemented relatively independently of the user interface levels that invoke the service and the business layer that is invoked. It also gives you half the chance of unit testing!

+3
source share

Do not boot lazily through the service interface. Define an explicit DTO and use them as your data contracts in WCF.

You can use NHibernate (or other ORMs) to properly select the objects needed to build the DTO.

+4
source share

You can try to use something based on REST (for example, ADO.NET Data Services ) and transparently wrap it in your client code.

+1
source share

All Articles