public static FilterDefinition <TDocument> EqOrNull <TDocument, TField>(
        this FilterDefinitionBuilder <TDocument> builder,
        Expression <Func <TDocument, object?> > field,
        TField value)
    {
        if (value is null)
        {
            return(builder.Type(field, BsonType.Null));
        }

        return(builder.Eq(field, value));
    }
Exemple #2
0
 public object Type(string property, DataType valueType)
 {
     return(InternalBuilder.Type(property, BsonTypeMapping[valueType]));
 }
 //
 // 摘要:
 //     Tests that the type of the named element is equal to some type (see $type).
 //
 // 参数:
 //   name:
 //     The name of the element to test.
 //
 //   type:
 //     The type to compare to.
 //
 // 返回结果:
 //     The builder (so method calls can be chained).
 public static FilterDefinition <BsonDocument> Type(string name, BsonType type)
 {
     return(filter.Type(name, type));
 }