ArcSpark76
ArcSpark76

Reputation: 76

ASP.NET cosmosDB, Ignore extra elements?

Just curious, I came from a Mongodb background but I'm making the switch to CosmosDBs core SQL database. I cant seem to find an ignore extra elements attributes(mongo has [BsonIgnoreExtraElements]. My cursory google searches have also not turned up much.

Anyone have any idea on this one?

Clarification

Basically CosmosDB doesn't have predefined classes setup(it basically stores raw json). Therefore, in the future should we add more elements to a database context class, we don't want our server to blow up. This is established in normal SQL with a bool you pass to the EF Core client, and on mongo with the mentioned attribute.

Additionally, I have looked at JsonIgnore. However, it would mean I would have to know ahead of time what element I wish to ignore.

I'm looking for something which will ignore all unknown elements. This will allow for flexibility to add elements to a context connected to the same database without compromising the operation of previous versions(Or without having to go back and edit old versions with JsonIgnore which can become quite the burden)

Upvotes: 0

Views: 672

Answers (1)

ArcSpark76
ArcSpark76

Reputation: 76

Sorry for wasting everyones time on this one. I decided to do a check myself and it appears that cosmos core defaults to ignoring extra elements, Which can be good or bad depending on how you look at it. Its important to note that it will throw exceptions if you switch it over to the mongo wrapper instead of core though.

Upvotes: 1

Related Questions