Skip to content

Commit 6d73cbd

Browse files
committed
upgrade to v2.30 driver
1 parent 4b6a6bc commit 6d73cbd

File tree

10 files changed

+153
-123
lines changed

10 files changed

+153
-123
lines changed

Benchmark/Benchmark.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<ItemGroup>
1616
<PackageReference Include="BenchmarkDotNet" Version="0.14.0"/>
17-
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.28.0"/>
17+
<PackageReference Include="MongoDB.Driver.GridFS" Version="2.30.0"/>
1818
</ItemGroup>
1919

2020
<ItemGroup>

MongoDB.Entities/Builders/Find.cs

+6-2
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ public Find<T, TProjection> Match(Template template)
151151
/// <param name="caseSensitive">Case sensitivity of the search (optional)</param>
152152
/// <param name="diacriticSensitive">Diacritic sensitivity of the search (optional)</param>
153153
/// <param name="language">The language for the search (optional)</param>
154-
public Find<T, TProjection> Match(Search searchType, string searchTerm, bool caseSensitive = false, bool diacriticSensitive = false, string? language = null)
154+
public Find<T, TProjection> Match(Search searchType,
155+
string searchTerm,
156+
bool caseSensitive = false,
157+
bool diacriticSensitive = false,
158+
string? language = null)
155159
{
156160
if (searchType != Search.Fuzzy)
157161
{
@@ -461,7 +465,7 @@ void AddTxtScoreToProjection(string propName)
461465

462466
options.Projection =
463467
options.Projection
464-
.Render(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry, Driver.Linq.LinqProvider.V3)
468+
.Render(new(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry))
465469
.Document.Add(propName, new BsonDocument { { "$meta", "textScore" } });
466470
}
467471
}

MongoDB.Entities/Builders/Update.cs

+5-2
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ public Update<T> Match(Search searchType, string searchTerm, bool caseSensitive
179179
/// <param name="nearCoordinates">The search point</param>
180180
/// <param name="maxDistance">Maximum distance in meters from the search point</param>
181181
/// <param name="minDistance">Minimum distance in meters from the search point</param>
182-
public Update<T> Match(Expression<Func<T, object?>> coordinatesProperty, Coordinates2D nearCoordinates, double? maxDistance = null, double? minDistance = null)
182+
public Update<T> Match(Expression<Func<T, object?>> coordinatesProperty,
183+
Coordinates2D nearCoordinates,
184+
double? maxDistance = null,
185+
double? minDistance = null)
183186
{
184187
return Match(f => f.Near(coordinatesProperty, nearCoordinates.ToGeoJsonPoint(), maxDistance, minDistance));
185188
}
@@ -503,7 +506,7 @@ bool ShouldSetModDate()
503506
Cache<T>.HasModifiedOn &&
504507
!Defs.Any(
505508
d => d
506-
.Render(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry, Driver.Linq.LinqProvider.V3)
509+
.Render(new(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry))
507510
.ToString()
508511
.Contains($"\"{Cache<T>.ModifiedOnPropName}\""));
509512
}

MongoDB.Entities/Builders/UpdateAndGet.cs

+7-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class UpdateAndGet<T, TProjection> : UpdateBase<T> where T : IEntity
3232
{
3333
readonly List<PipelineStageDefinition<T, TProjection>> _stages = new();
3434
FilterDefinition<T> _filter = Builders<T>.Filter.Empty;
35-
protected private readonly FindOneAndUpdateOptions<T, TProjection> options = new() { ReturnDocument = ReturnDocument.After };
35+
private protected readonly FindOneAndUpdateOptions<T, TProjection> options = new() { ReturnDocument = ReturnDocument.After };
3636
readonly IClientSessionHandle? _session;
3737
readonly Dictionary<Type, (object filterDef, bool prepend)>? _globalFilters;
3838
readonly Action<UpdateBase<T>>? _onUpdateAction;
@@ -107,7 +107,11 @@ public UpdateAndGet<T, TProjection> Match(Template template)
107107
/// <param name="caseSensitive">Case sensitivity of the search (optional)</param>
108108
/// <param name="diacriticSensitive">Diacritic sensitivity of the search (optional)</param>
109109
/// <param name="language">The language for the search (optional)</param>
110-
public UpdateAndGet<T, TProjection> Match(Search searchType, string searchTerm, bool caseSensitive = false, bool diacriticSensitive = false, string? language = null)
110+
public UpdateAndGet<T, TProjection> Match(Search searchType,
111+
string searchTerm,
112+
bool caseSensitive = false,
113+
bool diacriticSensitive = false,
114+
string? language = null)
111115
{
112116
if (searchType != Search.Fuzzy)
113117
{
@@ -457,7 +461,7 @@ bool ShouldSetModDate()
457461
Cache<T>.HasModifiedOn &&
458462
!Defs.Any(
459463
d => d
460-
.Render(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry, Driver.Linq.LinqProvider.V3)
464+
.Render(new(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry))
461465
.ToString()
462466
.Contains($"\"{Cache<T>.ModifiedOnPropName}\""));
463467
}

MongoDB.Entities/Core/Cache.cs

+5-4
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ static void Initialize()
5353
IdSetter = type.SetterForProp(IdPropName);
5454
}
5555
else
56-
throw new InvalidOperationException($"Type {type.FullName} must specify an Identity property. '_id', 'Id', 'ID', or [BsonId] annotation expected!");
56+
{
57+
throw new InvalidOperationException(
58+
$"Type {type.FullName} must specify an Identity property. '_id', 'Id', 'ID', or [BsonId] annotation expected!");
59+
}
5760

5861
Database = TypeMap.GetDatabase(type);
5962
DbName = Database.DatabaseNamespace.DatabaseName;
@@ -135,9 +138,7 @@ internal static ProjectionDefinition<T, TProjection> CombineWithRequiredProps<TP
135138
}
136139

137140
ProjectionDefinition<T> userProj = userProjection.Render(
138-
BsonSerializer.LookupSerializer<T>(),
139-
BsonSerializer.SerializerRegistry,
140-
LinqProvider.V3).Document;
141+
new(BsonSerializer.SerializerRegistry.GetSerializer<T>(), BsonSerializer.SerializerRegistry)).Document;
141142

142143
return Builders<T>.Projection.Combine(_requiredPropsProjection, userProj);
143144
}

0 commit comments

Comments
 (0)