BsonSerializationException: Creator map for class has 2 arguments, but none are configured

Viewed 102

I have a TextSearchJob object to store on MongoDB.

I am rather new with the database and I don't know why I have this error with the IDictionary version (on the right) while I have no error with the IEnumerable version(on the left): MongoDB.Bson.BsonSerializationException: Creator map for class TextSearchJob has 2 arguments, but none are configured.

Can someone explain this or point me to a documentation? Comparison of working and buggy versions

2 Answers

FieldName and his type should match to argument in ctor with the same name.

It appears that if the constructor parameter name matches the property name, it must be of the same type.
For my constructor, I wanted to have a type different from the property. So to solve my problem, I had to give a parameter name different from the property's to be able to use a different type... Go figure. :/

So, I just renamed my parameter inputs to kvInputs, and it worked.

Related