Your impressions so far seem correct. Currently the best approach is to use wrapper classes as you did. Besides the strong SoC, the two major issues that are avoided this way are:
1. WCF tries to load the whole object graph when an object is to be sent. As the lazy loading of the persistent objects cannot be switched off, copying just the necessary data to a proxy object and sending it through the service resolves the problem. Unfortunately this requires some additional code to be written.
2. If a persistent object is serialized, it is no longer connected to an object scope and both the lazy loading and change tracking are lost. As a result, when the object is sent back to the service to persist the changes made by the UI layer, you will have to load the original object and apply the changes from the received one.
Note that the caching mechanism is still working on the server side and if an object has already been loaded, it will not be retrieved from the database again. You can find more information on the supported caching strategies in the following blog posts:
Level one cache
Level two cache
You can take a look at our N-tier demo application with WCF
as well, if you have not found it already.
Another possible approach is to use the ObjectNetworkAttacher helper class which is distributed with Telerik OpenAccess ORM. It enables you to serialize and deserialize persistent object, as well as attaching them back to an object scope. However, there are some requirements for the classes - they should expose public id and version fields or implement the IDataObjectKey interface
. This is a relevant approach if you do not want to deal with proxy objects. More information on how to use the ObjectNetworkAttacher could be found in this help topic
Regarding your last question, I am afraid this is not possible at the moment.
All the best,
the Telerik team