Link to WCF serialization loop

I am trying to return lists of objects that have links to other objects and vice versa.

I want lazy loading to get "first-level children", I mean, if I have a "Man" object with the "Place" property, I want the place data to load, but not every object in "Place" should be loaded ... because it will be ahead of the circular reference ...

I read that I can do this using [DataContract (IsReference = true)] for each object.

I set every object in the model (automatically generated by EF) with this decoration, but it still fails to try to send it back to the caller of the service.

Did I miss something? Thanks in advance.

+3
source share
3 answers

I mean, if I have a Person object with the "Location" property, I want to load data, but not every object in the "Place" object needs to be loaded ...

This is not possible when using lazy loading. As soon as the object gets serialized, the serializer will gain access to each individual property. Access to each navigation property will cause lazy loading, and the serializer will continue to work with loaded properties => it will always serialize the complete graph of objects. In your scenario, this could mean:

  • The serializer will start with Person, which has a navigation property forPlace
  • A lost download will load Place, and the serializer will be serialized.
  • Place Persons, , Place!
  • Person - IsReference false, . , .

, , . , . , . , , .

. . , / ObjectContext , , .

WCF DTO , .

+4

[DataContract(IsReference=true)] . , , EF, , .

?

?

, - , ?

, TypeA-instance1 TypeB-instance1, TypeA-instance1, 2 TypeA-instance1 , ?

equals ​​ , , .

+5

, , .

+1

All Articles