Skip to content

Commit 3f67611

Browse files
committed
feat: Upgrade major mongo version
1 parent 165c32a commit 3f67611

File tree

8 files changed

+16
-10
lines changed

8 files changed

+16
-10
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<PackageVersion Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.4" />
1414
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.4" />
1515
<PackageVersion Include="Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions" Version="9.0.4" />
16-
<PackageVersion Include="MongoDB.Driver" Version="2.30.0" />
16+
<PackageVersion Include="MongoDB.Driver" Version="3.3.0" />
1717
<PackageVersion Include="Pomelo.EntityFrameworkCore.MySql" Version="9.0.0-preview.3.efcore.9.0.0" />
1818
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.4" />
1919
<PackageVersion Include="RavenDB.Client" Version="7.0.2" />

src/LinkDotNet.Blog.Infrastructure/Persistence/CachedRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async ValueTask<IPagedList<T>> GetAllAsync(Expression<Func<T, bool>>? fil
3737
await repository.GetAllAsync(filter, orderBy, descending, page, pageSize);
3838

3939
public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
40-
Expression<Func<T, TProjection>>? selector,
40+
Expression<Func<T, TProjection>> selector,
4141
Expression<Func<T, bool>>? filter = null,
4242
Expression<Func<T, object>>? orderBy = null,
4343
bool descending = true,

src/LinkDotNet.Blog.Infrastructure/Persistence/IRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ValueTask<IPagedList<TEntity>> GetAllAsync(
2222
int pageSize = int.MaxValue);
2323

2424
ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
25-
Expression<Func<TEntity, TProjection>>? selector,
25+
Expression<Func<TEntity, TProjection>> selector,
2626
Expression<Func<TEntity, bool>>? filter = null,
2727
Expression<Func<TEntity, object>>? orderBy = null,
2828
bool descending = true,

src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/MongoDBConnectionProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ public static class MongoDBConnectionProvider
88
{
99
public static IMongoDatabase Create(string connectionString, string databaseName)
1010
{
11+
#pragma warning disable IDISP001 // Handled by DI container
12+
#pragma warning disable CA2000 // Handled by DI container
1113
var client = new MongoClient(connectionString);
14+
#pragma warning restore CA2000
15+
#pragma warning restore IDISP001
1216
BsonClassMap.RegisterClassMap<Entity>(cm =>
1317
{
1418
cm.AutoMap();

src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/PaginatedListQueryExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
using System.Linq;
12
using System.Threading;
23
using System.Threading.Tasks;
3-
using MongoDB.Driver;
44
using MongoDB.Driver.Linq;
55

66
namespace LinkDotNet.Blog.Infrastructure.Persistence.MongoDB;
77

88
public static class PaginatedListQueryExtensions
99
{
10-
public static async Task<IPagedList<T>> ToPagedListAsync<T>(this IMongoQueryable<T> source, int pageIndex, int pageSize, CancellationToken token = default)
10+
public static async Task<IPagedList<T>> ToPagedListAsync<T>(this IQueryable<T> source, int pageIndex, int pageSize, CancellationToken token = default)
1111
{
1212
var count = await source.CountAsync(token);
1313
if (count > 0)

src/LinkDotNet.Blog.Infrastructure/Persistence/MongoDB/Repository.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Linq;
34
using System.Linq.Expressions;
45
using System.Threading.Tasks;
56
using LinkDotNet.Blog.Domain;
@@ -51,7 +52,7 @@ public async ValueTask<IPagedList<TEntity>> GetAllAsync(Expression<Func<TEntity,
5152
await GetAllByProjectionAsync(s => s, filter, orderBy, descending, page, pageSize);
5253

5354
public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
54-
Expression<Func<TEntity, TProjection>>? selector,
55+
Expression<Func<TEntity, TProjection>> selector,
5556
Expression<Func<TEntity, bool>>? filter = null,
5657
Expression<Func<TEntity, object>>? orderBy = null,
5758
bool descending = true,
@@ -70,8 +71,9 @@ public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProject
7071
query = descending ? query.OrderByDescending(orderBy) : query.OrderBy(orderBy);
7172
}
7273

73-
var projectionQuery = query.Select(selector);
74-
return await projectionQuery.ToPagedListAsync(page, pageSize);
74+
return await query
75+
.Select(selector)
76+
.ToPagedListAsync(page, pageSize);
7577
}
7678

7779
public async ValueTask StoreAsync(TEntity entity)

src/LinkDotNet.Blog.Infrastructure/Persistence/RavenDb/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public ValueTask<IPagedList<TEntity>> GetAllAsync(Expression<Func<TEntity, bool>
4747
GetAllByProjectionAsync(s => s, filter, orderBy, descending, page, pageSize);
4848

4949
public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
50-
Expression<Func<TEntity, TProjection>>? selector,
50+
Expression<Func<TEntity, TProjection>> selector,
5151
Expression<Func<TEntity, bool>>? filter = null,
5252
Expression<Func<TEntity, object>>? orderBy = null,
5353
bool descending = true,

src/LinkDotNet.Blog.Infrastructure/Persistence/Sql/Repository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ValueTask<IPagedList<TEntity>> GetAllAsync(Expression<Func<TEntity, bool>
5050
GetAllByProjectionAsync(s => s, filter, orderBy, descending, page, pageSize);
5151

5252
public async ValueTask<IPagedList<TProjection>> GetAllByProjectionAsync<TProjection>(
53-
Expression<Func<TEntity, TProjection>>? selector,
53+
Expression<Func<TEntity, TProjection>> selector,
5454
Expression<Func<TEntity, bool>>? filter = null,
5555
Expression<Func<TEntity, object>>? orderBy = null,
5656
bool descending = true,

0 commit comments

Comments
 (0)