Do we still need to convert an OA object to a proxy, or can I decrotate the properties with an attribute to just cherrypick the serialized fields to JSON?
1 Answer, 1 is accepted
0
Simeon Simeonov
Telerik team
answered on 12 May 2016, 08:12 PM
Hello Steve,
You can decorate the entity class and serialize it directly but this is not advisable. This can cause problems especially with navigation properties. In general we always advice to use dedicated DTO objects that define explicitly the contract object that will be serialized.
If you decide to serialize the entity object directly I would advice to create a detach copy of the object and serialize this new object. The reason is that in Telerik Data Access - navigation properties are lazy loaded. This means that out of the box when the serializer calls a navigation (reference or collection) property it will be loaded from the database and then serialized. The result is that if you ask for a single object you may load substantial portion of your data if there are navigation properties in the target entity type. To overcome this behavior I suggest that you use CreateDetachedCopy method to disable lazy loading during serialization and control what portions of your object graph is sent to the client.
Also for an example please check Dimitar Tachev answer here.
Regards,
Simeon Simeonov
Telerik
Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.