I have a somewhat complex class that may or may not contain a list of elements of the same type
Class Items { List<Items> SubItems ... }
The class itself is serializable, however, it is a huge waste of space for serializing objects in the list, since they are serialized and added to the database before being included in the list.
Is it possible to indicate that the list should be represented as a list of integers when it is serialized?
Note. These integers will represent the primary keys of the rows in which the serialized object is located.
source share