Closed azhe403 closed 1 year ago
Hey @azhe403 , you can ignore extra elements with an attribute on the model you want to ignore them on.
See the docs here: https://github.com/TurnerSoftware/MongoFramework/blob/main/README.md#Extra-Elements
I'm not sure what you mean about a default values though. By ignoring an element, there would be no property to put a default value on.
Hi @Turnerj
In my case is a renaming column from CendolsCount
to CendolCount
, so old data still with previous field, but changed column will be applied to new data.
I think it not by adding attribute, but leave old data with old field and return default value (e.g. null, zero or false) when query them.
OK so this could be a bit of a complicated scenario.
Column
attribute to map a property to an arbitrary element. (eg. property CendolCount
maps to element CendolsCount
)CendolCount
). Alternatively to ignoring the extra elements, you can add a new property with type IDictionary<string, object>
with an ExtraElements
attribute on it. This will hide the error you're seeing and make the data available through that dictionary.The only other option is performing some sort of migration but you'll be on your own for that. I do have plans to do some sort of migration system for MongoFramework but that would be a long time out.
Seem that all can be solved with ExtraElements
, i has tried and worked like as expected.
thanks for making this lib great!
I'll close this issue.
When found an unknown field, is there option for ignore field and return default value of field depend on field type?