简体   繁体   中英

Serialize EntitySet<T> c#

I would like some help with ac# issue. I have a customer class which has an EntitySet<Book> . The class is marked Serializable so that I can serialize it with a BinaryFormatter . The problem is that the EntitySet is not serializable.

I need to serialize it manually with a MemoryStream . Does anyone know how to achieve this? A code sample would be great!

Via the use of reflection you can step over the public and private fields as well as the class name and the parent you inherit from of the instantiated object.

Output these values to a string save it to a memorystream which you can read from later and then create a new object with reflection based on the type found.

Currently unable to give a more clear example. But this is one of the many ways to go

我使用代理序列化程序修复它: https//msdn.microsoft.com/en-us/magazine/cc188950.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM