1

I have two objects with a many to many relationship, let's call them Book and Category. The standard thing to do in Entity Framework - Code First would be to map them together and put a navigation property on either side, which I have done. I am working in a detached context, so I need to serialize my objects. So if I have two Book objects and three Category objects, one of which is shared by the two Book objects, do I suffer a performance loss by serializing the Book objects as they are by serializing the shared Category twice? Would it be beneficial performance-wise to serialize my Book objects and Category objects separately and rebuild the relationship post-serialization?

I suppose it might depend on the serializer. If anyone has any other tips on the best method to go about this, I would appreciate any advice.

Alec
  • 1,646
  • 3
  • 19
  • 35

1 Answers1

0

You need to use serialization with reference tracking (you must do it anyway if you have navigation properties from Book to Category and from Category to Book otherwise you will get circular reference exception). Once you use this serialization each your entity will be serialized only once.

Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • The thing is I only use one navigation property, so it's one sided, so no circular references. – Alec Jan 31 '12 at 12:00
  • But the point is still the same. If you want to avoid duplicities you need serialization process which is able to track dependencies. What serialization are you going to use? – Ladislav Mrnka Jan 31 '12 at 12:08