|
Simple scenario here:
Trying to do a simple find on a field that is set to "IgnoreIfDefault", and thus is not a field in the document if the value is the default. However, this causes problems with querying...
Collection.Find(d => d.ActiveState == ActiveStateType.Active).ToListAsync().Result
|
With this class:
public class JebsClass {
|
[BsonIgnoreIfDefault]
|
[BsonDefaultValue(ActiveStateType.Active)]
|
public ActiveStateType ActiveState { get; set; }
|
public int Field1 {get; set; }
|
}
|
This finds records like this
{
|
Field1: 5,
|
ActiveState: "Active"
|
}
|
but NOT documents like this
It seems to me that the Find interface methods should take into account Default values, and update the translated query to include a $exists: false for ActiveState.
|