Hi.
FilterDefinitionBuilder could accept string as first parameter for all of their method. Like this:
var filterDefinition = Builders<Employee>.Filter.Eq("fieldName", "someValue");
Does this field should match property name of my model or it should match field name from document?
My issue that filter definition renders inproper query for date field if provided field name string doesnt match my model property name exactly.
In following example "dateOfBirth" doesn't mapped to model field Employee.DateOfBirth
var filterDefinition = Builders<Employee>.Filter.Eq("dateOfBirth", "2019-01-16"); mongoFilterDefinition.Render(coll.DocumentSerializer, coll.Settings.SerializerRegistry) // returns { "dateOfBirth" : "2019-01-16" }
And this filter doesn't work.
But if we will provide field name like "DateOfBirth" it will be mapped:
var filterDefinition = Builders<Employee>.Filter.Eq("DateOfBirth", "2019-01-16"); mongoFilterDefinition.Render(coll.DocumentSerializer, coll.Settings.SerializerRegistry) // returns { "dateOfBirth" : ISODate("2019-01-16T00:00:00Z") }
I found a place where this behaviour could be changed but I'm not sure if it's a bug.