Programmatically set properties to exclude from serialization

前端 未结 7 1169
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-30 07:19

Is it possible to programmatically set that you want to exclude a property from serialization?

Example:

  • When de-serializing, I want to load up an ID fi
7条回答
  •  天涯浪人
    2020-12-30 07:26

    If you want to include field during serialization but ignore it during deserialization then you can use OnDeserializedAttribute to run a method which will set default value for ID field.

提交回复
热议问题