I’m currently working on a blazor wasm app and am using Mongo DB Driver with Mongo DB Atlas for my data.
For some simplification I wanted to add an interface to my models which end up in the database. This interface is just one property which I only wanted to use the getter from to indicate what should be the key for the database search. It’s basically just a mapping of already existing properties of the model, like the name or the mail adresse or anything to this generic key property which only has a getter, so that I can use that with the IAsnycCursor to find the elements with this Key.
My issue with that, is that it throws an error InvalidOperationException: Serializer for "MyClass" does not have a member named Key.
I figured, that it might has issues with it being a property and tried to use a function instead with a different exception but still not working.
This “Key” property should not get de/serialized in any case it should just point to another member variable or anything. That’s why I also added the [BsonIgnore] to the field but with no effect to my exception.
It would be nice if this could work somehow? Maybe I did something wrong or so, I appreciate any help.
Hi Kevin! I’m happy to help. I’ll need a bit more context to be of assistance. Could you share a self-contained repro (a simple console application will do)?