Skip to content

BsonKnownTypes Attribute Support #8

@Turnerj

Description

@Turnerj

While MongoFramework handles polymorphism when dealing with a derived type, there isn't functionality to support something like the MongoDB C# Driver's BsonKnownTypes attribute.

You can still use the native one but it doesn't apply any additional mapping through MongoFramework's entity mapper.

It might be useful to just leverage that exact attribute and make a custom mapping processor use it to apply entity mapping that is native to MongoFramework.

It would be ideal to just make this apply at runtime and for some things it is possible. It is possible to apply runtime mapping for any writes (as the entity type is available) however runtime mapping for reads is both complex and would impact performance.

Assuming one could inject code into the serialization process for the C# driver, it would be taking the string type discriminator in the DB and finding the right type in the right assembly to convert to. This is possible with reflection but is a pretty average solution.

Metadata

Metadata

Assignees

Labels

enhancementEnhancements & features

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions