Serializing C# objects to DB
Posted
by Robert Koritnik
on Stack Overflow
See other posts from Stack Overflow
or by Robert Koritnik
Published on 2010-04-14T15:13:30Z
Indexed on
2010/04/14
15:23 UTC
Read the original article
Hit count: 364
I'm using a DB table with various different entities. This means that I can't have an arbitrary number of fields in it to save all kinds of different entities. I want instead save just the most important fields (dates, reference IDs - kind of foreign key to various other tables, most important text fields etc.) and an additional text field where I'd like to store more complete object data.
the most obvious solution would be to use XML
strings and store those. The second most obvious choice would be JSON
, that usually shorter and probably also faster to serialize/deserialize... And is probably also faster. But is it really? My objects also wouldn't need to be strictly serializable, because JsonSerializer is usually able to serialize anything. Even anonymous objects, that may as well be used here.
What would be the most optimal solution to solve this problem?
© Stack Overflow or respective owner