@@ -98,17 +98,17 @@ public EncryptedCollectionBuilder<TDocument> EncryptMetadata(Guid? keyId = null,
98
98
/// </summary>
99
99
public EncryptedCollectionBuilder < TDocument > PatternProperty (
100
100
string pattern ,
101
- BsonType bsonType ,
101
+ BsonType ? bsonType = null ,
102
102
EncryptionAlgorithm ? algorithm = null ,
103
103
Guid ? keyId = null )
104
- => PatternProperty ( pattern , [ bsonType ] , algorithm , keyId ) ;
104
+ => PatternProperty ( pattern , bsonType is null ? [ ] : [ bsonType . Value ] , algorithm , keyId ) ;
105
105
106
106
/// <summary>
107
107
/// //TODO
108
108
/// </summary>
109
109
public EncryptedCollectionBuilder < TDocument > PatternProperty (
110
110
string pattern ,
111
- IEnumerable < BsonType > bsonTypes ,
111
+ IEnumerable < BsonType > bsonTypes = null ,
112
112
EncryptionAlgorithm ? algorithm = null ,
113
113
Guid ? keyId = null )
114
114
{
@@ -145,17 +145,17 @@ public EncryptedCollectionBuilder<TDocument> PatternProperty<TField>(
145
145
/// </summary>
146
146
public EncryptedCollectionBuilder < TDocument > Property < TField > (
147
147
Expression < Func < TDocument , TField > > path ,
148
- BsonType bsonType ,
148
+ BsonType ? bsonType = null ,
149
149
EncryptionAlgorithm ? algorithm = null ,
150
150
Guid ? keyId = null )
151
- => Property ( path , [ bsonType ] , algorithm , keyId ) ;
151
+ => Property ( path , bsonType is null ? null : [ bsonType . Value ] , algorithm , keyId ) ;
152
152
153
153
/// <summary>
154
154
/// //TODO
155
155
/// </summary>
156
156
public EncryptedCollectionBuilder < TDocument > Property < TField > (
157
157
Expression < Func < TDocument , TField > > path ,
158
- IEnumerable < BsonType > bsonTypes ,
158
+ IEnumerable < BsonType > bsonTypes = null ,
159
159
EncryptionAlgorithm ? algorithm = null ,
160
160
Guid ? keyId = null )
161
161
=> Property ( new ExpressionFieldDefinition < TDocument , TField > ( path ) , bsonTypes , algorithm , keyId ) ;
@@ -165,17 +165,17 @@ public EncryptedCollectionBuilder<TDocument> Property<TField>(
165
165
/// </summary>
166
166
public EncryptedCollectionBuilder < TDocument > Property (
167
167
FieldDefinition < TDocument > path ,
168
- BsonType bsonType ,
168
+ BsonType ? bsonType = null ,
169
169
EncryptionAlgorithm ? algorithm = null ,
170
170
Guid ? keyId = null )
171
- => Property ( path , [ bsonType ] , algorithm , keyId ) ;
171
+ => Property ( path , bsonType is null ? null : [ bsonType . Value ] , algorithm , keyId ) ;
172
172
173
173
/// <summary>
174
174
/// //TODO
175
175
/// </summary>
176
176
public EncryptedCollectionBuilder < TDocument > Property (
177
177
FieldDefinition < TDocument > path ,
178
- IEnumerable < BsonType > bsonTypes ,
178
+ IEnumerable < BsonType > bsonTypes = null ,
179
179
EncryptionAlgorithm ? algorithm = null ,
180
180
Guid ? keyId = null )
181
181
{
@@ -210,7 +210,7 @@ public EncryptedCollectionBuilder<TDocument> Property<TField>(
210
210
internal BsonDocument Build ( ) => _schema ;
211
211
212
212
private static BsonDocument CreateEncryptDocument (
213
- IEnumerable < BsonType > bsonTypes ,
213
+ IEnumerable < BsonType > bsonTypes = null ,
214
214
EncryptionAlgorithm ? algorithm = null ,
215
215
Guid ? keyId = null )
216
216
{
@@ -268,7 +268,7 @@ private void AddToProperties(string field, BsonDocument document)
268
268
properties [ field ] = document ;
269
269
}
270
270
271
- private static string MapBsonTypeToString ( BsonType type ) //TODO Taken from AstTypeFilterOperation, do we have a common place where this could go?
271
+ private static string MapBsonTypeToString ( BsonType type )
272
272
{
273
273
return type switch
274
274
{
@@ -283,16 +283,12 @@ private void AddToProperties(string field, BsonDocument document)
283
283
BsonType . Int64 => "long" ,
284
284
BsonType . JavaScript => "javascript" ,
285
285
BsonType . JavaScriptWithScope => "javascriptWithScope" ,
286
- BsonType . MaxKey => "maxKey" ,
287
- BsonType . MinKey => "minKey" ,
288
- BsonType . Null => "null" ,
289
286
BsonType . ObjectId => "objectId" ,
290
287
BsonType . RegularExpression => "regex" ,
291
288
BsonType . String => "string" ,
292
289
BsonType . Symbol => "symbol" ,
293
290
BsonType . Timestamp => "timestamp" ,
294
- BsonType . Undefined => "undefined" ,
295
- _ => throw new ArgumentException ( $ "Unexpected BSON type: { type } .", nameof ( type ) )
291
+ _ => throw new ArgumentException ( $ "Unsupported BSON type: { type } .", nameof ( type ) )
296
292
} ;
297
293
}
298
294
0 commit comments