diff --git a/Directory.Packages.props b/Directory.Packages.props
index 3e8410e9c4..8cd134d1d8 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -37,6 +37,10 @@
+
+
+
+
@@ -111,7 +115,7 @@
-
+
diff --git a/build/common.ps1 b/build/common.ps1
index 85f18edb21..51ab56d972 100644
--- a/build/common.ps1
+++ b/build/common.ps1
@@ -34,11 +34,13 @@ if ($full -eq "-f")
"../templates/module/aspnet-core",
"../templates/app/aspnet-core",
"../templates/console",
- "../templates/wpf",
"../templates/app-nolayers/aspnet-core",
"../abp_io/AbpIoLocalization",
"../source-code"
- )
+ )
+ if ($env:OS -eq "Windows_NT") {
+ $solutionPaths += "../templates/wpf"
+ }
}else{
Write-host ""
Write-host ":::::::::::::: !!! You are in development mode !!! ::::::::::::::" -ForegroundColor red -BackgroundColor yellow
diff --git a/docs/en/framework/architecture/best-practices/mongodb-integration.md b/docs/en/framework/architecture/best-practices/mongodb-integration.md
index 1930984e2e..c39f6443a0 100644
--- a/docs/en/framework/architecture/best-practices/mongodb-integration.md
+++ b/docs/en/framework/architecture/best-practices/mongodb-integration.md
@@ -114,7 +114,7 @@ public async Task FindByNormalizedUserNameAsync(
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
- return await (await GetMongoQueryableAsync())
+ return await (await GetQueryableAsync())
.FirstOrDefaultAsync(
u => u.NormalizedUserName == normalizedUserName,
GetCancellationToken(cancellationToken)
@@ -125,10 +125,10 @@ public async Task FindByNormalizedUserNameAsync(
`GetCancellationToken` fallbacks to the `ICancellationTokenProvider.Token` to obtain the cancellation token if it is not provided by the caller code.
* **Do** ignore the `includeDetails` parameters for the repository implementation since MongoDB loads the aggregate root as a whole (including sub collections) by default.
-* **Do** use the `GetMongoQueryableAsync()` method to obtain an `IQueryable` to perform queries wherever possible. Because;
- * `GetMongoQueryableAsync()` method automatically uses the `ApplyDataFilters` method to filter the data based on the current data filters (like soft delete and multi-tenancy).
+* **Do** use the `GetQueryableAsync()` method to obtain an `IQueryable` to perform queries wherever possible. Because;
+ * `GetQueryableAsync()` method automatically uses the `ApplyDataFilters` method to filter the data based on the current data filters (like soft delete and multi-tenancy).
* Using `IQueryable` makes the code as much as similar to the EF Core repository implementation and easy to write and read.
-* **Do** implement data filtering if it is not possible to use the `GetMongoQueryable()` method.
+* **Do** implement data filtering if it is not possible to use the `GetQueryableAsync()` method.
## Module Class
diff --git a/docs/en/framework/architecture/domain-driven-design/repositories.md b/docs/en/framework/architecture/domain-driven-design/repositories.md
index 9050e7d3c3..04848a59e8 100644
--- a/docs/en/framework/architecture/domain-driven-design/repositories.md
+++ b/docs/en/framework/architecture/domain-driven-design/repositories.md
@@ -393,19 +393,6 @@ This method is suggested;
* If you are developing an application and you **don't plan to change** EF Core in the future, or you can **tolerate** it if you need to change it later. We believe that's reasonable if you are developing a final application.
-#### MongoDB Case
-
-If you are using [MongoDB](../../data/mongodb), you need to add the [Volo.Abp.MongoDB](https://www.nuget.org/packages/Volo.Abp.MongoDB) NuGet package to your project. Even in this case, you can't directly use async LINQ extensions (like `ToListAsync`) because MongoDB doesn't provide async extension methods for `IQueryable`, but provides for `IMongoQueryable`. You need to cast the query to `IMongoQueryable` first to be able to use the async extension methods.
-
-**Example: Cast `IQueryable` to `IMongoQueryable` and use `ToListAsync()`**
-
-````csharp
-var queryable = await _personRepository.GetQueryableAsync();
-var people = ((IMongoQueryable) queryable
- .Where(p => p.Name.Contains(nameFilter)))
- .ToListAsync();
-````
-
### Option-2: Use the IRepository Async Extension Methods
ABP provides async extension methods for the repositories, just similar to async LINQ extension methods.
diff --git a/docs/en/guides/microservice-mongodb.md b/docs/en/guides/microservice-mongodb.md
index c9b63ecf4e..087668ba7a 100644
--- a/docs/en/guides/microservice-mongodb.md
+++ b/docs/en/guides/microservice-mongodb.md
@@ -97,9 +97,9 @@ Here we use `BookStore.ProductService` project as an example:
int skipCount = 0,
CancellationToken cancellationToken = default)
{
- var query = ApplyFilter(await GetMongoQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
+ var query = ApplyFilter(await GetQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
query = query.OrderBy(string.IsNullOrWhiteSpace(sorting) ? ProductConsts.GetDefaultSorting(false) : sorting);
- return await query.As>().PageBy>(skipCount, maxResultCount).ToListAsync(cancellationToken);
+ return await query.PageBy(skipCount, maxResultCount).ToListAsync(cancellationToken);
}
public async Task GetCountAsync(
@@ -109,8 +109,8 @@ Here we use `BookStore.ProductService` project as an example:
float? priceMax = null,
CancellationToken cancellationToken = default)
{
- var query = ApplyFilter(await GetMongoQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
- return await query.As>().LongCountAsync(GetCancellationToken(cancellationToken));
+ var query = ApplyFilter(await GetQueryableAsync(cancellationToken), filterText, name, priceMin, priceMax);
+ return await query.LongCountAsync(GetCancellationToken(cancellationToken));
}
protected virtual IQueryable ApplyFilter(
diff --git a/docs/en/release-info/migration-guides/MongoDB-Driver-2-to-3.md b/docs/en/release-info/migration-guides/MongoDB-Driver-2-to-3.md
new file mode 100644
index 0000000000..79c0d70573
--- /dev/null
+++ b/docs/en/release-info/migration-guides/MongoDB-Driver-2-to-3.md
@@ -0,0 +1,59 @@
+# Migrating from MongoDB Driver 2 to 3
+
+## Introduction
+
+The release of MongoDB Driver 3 includes numerous user-requested fixes and improvements that were deferred in previous versions due to backward compatibility concerns. It also features internal improvements to reduce technical debt and enhance maintainability. One major update is the removal of a significant portion of the public API (primarily from `MongoDB.Driver.Core`), which was not intended for public use. The removed APIs were marked as deprecated in version 2.30.0.
+
+Please refer to the [upgrade guide](https://www.mongodb.com/docs/drivers/csharp/current/upgrade/v3/) for a complete list of breaking changes and upgrade guidelines.
+
+## Repository Changes
+
+Some method signatures in the `MongoDbRepository` class have been updated because the `IMongoQueryable` has been removed. The specific changes are as follows:
+
+- The new `GetQueryableAsync` method has been added to return `IQueryable`.
+- The `GetMongoQueryable` and `GetMongoQueryableAsync` methods return `IQueryable` instead of `IMongoQueryable`,
+- The `GetMongoQueryable` and `GetMongoQueryableAsync` methods are marked as obsolete, You should use the new `GetQueryableAsync` method instead.
+
+Please update your application by searching for and replacing these method calls.
+
+> The return value of the `GetQueryableAsync` method is `IQueryable`, which can be used directly to perform queries, similar to EF Core. Remove all instances of `IMongoQueryable` in your project and replace them with `IQueryable`.
+
+**Previous code example:**
+
+```csharp
+var myEntity = await (await GetMongoQueryableAsync()).As>().FirstOrDefaultAsync(x => x.Id == id);
+```
+
+**Updated code example:**
+
+```csharp
+var myEntity = await GetQueryableAsync().FirstOrDefaultAsync(x => x.Id == id);
+```
+
+## Unit Test Changes
+
+Previously, we used the [EphemeralMongo](https://github.com/asimmon/ephemeral-mongo) library for unit testing. However, it does not support the latest version of [MongoDB.Driver 3.x](https://github.com/mongodb/mongo-go-driver). You should replace it with [MongoSandbox](https://github.com/wassim-k/MongoSandbox).
+
+In your unit test project files, replace the following:
+
+```xml
+
+
+
+
+```
+
+With:
+
+```xml
+
+
+
+
+```
+
+In your unit test classes, replace `using EphemeralMongo` with `using MongoSandbox`.
+
+## Official Upgrade Guide
+
+We recommend reviewing the [upgrade guide](https://www.mongodb.com/docs/drivers/csharp/current/upgrade/v3/) for MongoDB Driver 3 to ensure a smooth migration process.
diff --git a/docs/en/tutorials/book-store/part-07.md b/docs/en/tutorials/book-store/part-07.md
index 0708ecfcb9..92108c4a35 100644
--- a/docs/en/tutorials/book-store/part-07.md
+++ b/docs/en/tutorials/book-store/part-07.md
@@ -180,7 +180,7 @@ public class MongoDbAuthorRepository
public async Task FindByNameAsync(string name)
{
- var queryable = await GetMongoQueryableAsync();
+ var queryable = await GetQueryableAsync();
return await queryable.FirstOrDefaultAsync(author => author.Name == name);
}
@@ -190,14 +190,13 @@ public class MongoDbAuthorRepository
string sorting,
string filter = null)
{
- var queryable = await GetMongoQueryableAsync();
+ var queryable = await GetQueryableAsync();
return await queryable
- .WhereIf>(
+ .WhereIf>(
!filter.IsNullOrWhiteSpace(),
author => author.Name.Contains(filter)
)
.OrderBy(sorting)
- .As>()
.Skip(skipCount)
.Take(maxResultCount)
.ToListAsync();
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
index a687ba2bf9..acd905b8c6 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/IMongoDbRepository.cs
@@ -1,8 +1,8 @@
using System;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Entities;
namespace Volo.Abp.Domain.Repositories.MongoDB;
@@ -20,10 +20,13 @@ public interface IMongoDbRepository : IRepository
Task> GetCollectionAsync(CancellationToken cancellationToken = default);
- [Obsolete("Use GetMongoQueryableAsync method.")]
- IMongoQueryable GetMongoQueryable();
+ [Obsolete("Use GetQueryable method.")]
+ IQueryable GetMongoQueryable();
- Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
+ [Obsolete("Use GetQueryableAsync method.")]
+ Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
+
+ Task> GetQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
Task> GetAggregateAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null);
}
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
index 45629f76e5..fdc7464d6b 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs
@@ -455,19 +455,19 @@ public class MongoDbRepository
public async override Task> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
- return await (await GetMongoQueryableAsync(cancellationToken)).ToListAsync(cancellationToken);
+ return await (await GetQueryableAsync(cancellationToken)).ToListAsync(cancellationToken);
}
public async override Task> GetListAsync(Expression> predicate, bool includeDetails = false, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
- return await (await GetMongoQueryableAsync(cancellationToken)).Where(predicate).ToListAsync(cancellationToken);
+ return await (await GetQueryableAsync(cancellationToken)).Where(predicate).ToListAsync(cancellationToken);
}
public async override Task GetCountAsync(CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
- return await (await GetMongoQueryableAsync(cancellationToken)).LongCountAsync(cancellationToken);
+ return await (await GetQueryableAsync(cancellationToken)).LongCountAsync(cancellationToken);
}
public async override Task> GetPagedListAsync(
@@ -479,10 +479,9 @@ public class MongoDbRepository
{
cancellationToken = GetCancellationToken(cancellationToken);
- return await (await GetMongoQueryableAsync(cancellationToken))
+ return await (await GetQueryableAsync(cancellationToken))
.OrderByIf>(!sorting.IsNullOrWhiteSpace(), sorting)
- .As>()
- .PageBy>(skipCount, maxResultCount)
+ .PageBy>(skipCount, maxResultCount)
.ToListAsync(cancellationToken);
}
@@ -493,14 +492,14 @@ public class MongoDbRepository
{
cancellationToken = GetCancellationToken(cancellationToken);
- var entities = await (await GetMongoQueryableAsync(cancellationToken))
+ var entities = await (await GetQueryableAsync(cancellationToken))
.Where(predicate)
.ToListAsync(cancellationToken);
await DeleteManyAsync(entities, autoSave, cancellationToken);
}
- public override async Task DeleteDirectAsync(Expression> predicate, CancellationToken cancellationToken = default)
+ public async override Task DeleteDirectAsync(Expression> predicate, CancellationToken cancellationToken = default)
{
cancellationToken = GetCancellationToken(cancellationToken);
@@ -527,12 +526,16 @@ public class MongoDbRepository
[Obsolete("Use GetQueryableAsync method.")]
protected override IQueryable GetQueryable()
{
- return GetMongoQueryable();
+ return ApplyDataFilters(
+ SessionHandle != null
+ ? Collection.AsQueryable(SessionHandle)
+ : Collection.AsQueryable()
+ );
}
public async override Task> GetQueryableAsync()
{
- return await GetMongoQueryableAsync();
+ return await GetQueryableAsync();
}
public async override Task FindAsync(
@@ -542,34 +545,36 @@ public class MongoDbRepository
{
cancellationToken = GetCancellationToken(cancellationToken);
- return await (await GetMongoQueryableAsync(cancellationToken))
+ return await (await GetQueryableAsync(cancellationToken))
.Where(predicate)
.SingleOrDefaultAsync(cancellationToken);
}
- [Obsolete("Use GetMongoQueryableAsync method.")]
- public virtual IMongoQueryable GetMongoQueryable()
+ [Obsolete("Use GetQueryableAsync method.")]
+ public virtual IQueryable GetMongoQueryable()
{
- return ApplyDataFilters(
- SessionHandle != null
- ? Collection.AsQueryable(SessionHandle)
- : Collection.AsQueryable()
- );
+ return GetQueryable();
+ }
+
+ [Obsolete("Use GetQueryableAsync method.")]
+ public virtual Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null)
+ {
+ return GetQueryableAsync(cancellationToken, options);
}
- public virtual Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
+ public virtual async Task> GetQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? options = null)
{
- return GetMongoQueryableAsync(cancellationToken, aggregateOptions);
+ return await GetQueryableAsync(cancellationToken, options);
}
- protected virtual async Task> GetMongoQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
+ protected virtual async Task> GetQueryableAsync(CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
{
cancellationToken = GetCancellationToken(cancellationToken);
var dbContext = await GetDbContextAsync(cancellationToken);
var collection = dbContext.Collection();
- return ApplyDataFilters, TOtherEntity>(
+ return ApplyDataFilters, TOtherEntity>(
dbContext.SessionHandle != null
? collection.AsQueryable(dbContext.SessionHandle, aggregateOptions)
: collection.AsQueryable(aggregateOptions)
@@ -810,7 +815,7 @@ public class MongoDbRepository
{
cancellationToken = GetCancellationToken(cancellationToken);
- return await (await GetMongoQueryableAsync(cancellationToken))
+ return await (await GetQueryableAsync(cancellationToken))
.Where(x => x.Id!.Equals(id))
.FirstOrDefaultAsync(cancellationToken);
}
@@ -827,7 +832,7 @@ public class MongoDbRepository
{
cancellationToken = GetCancellationToken(cancellationToken);
- var entities = await (await GetMongoQueryableAsync(cancellationToken))
+ var entities = await (await GetQueryableAsync(cancellationToken))
.Where(x => ids.Contains(x.Id))
.ToListAsync(cancellationToken);
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
index 676450a5b8..353185c8e3 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDbCoreRepositoryExtensions.cs
@@ -1,8 +1,8 @@
using System;
+using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
-using MongoDB.Driver.Linq;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Repositories.MongoDB;
@@ -36,19 +36,26 @@ public static class MongoDbCoreRepositoryExtensions
return repository.ToMongoDbRepository().GetCollectionAsync(cancellationToken);
}
- [Obsolete("Use GetMongoQueryableAsync method.")]
- public static IMongoQueryable GetMongoQueryable(this IReadOnlyBasicRepository repository)
+ [Obsolete("Use GetQueryableAsync method.")]
+ public static IQueryable GetMongoQueryable(this IReadOnlyBasicRepository repository)
where TEntity : class, IEntity
{
return repository.ToMongoDbRepository().GetMongoQueryable();
}
- public static Task> GetMongoQueryableAsync(this IReadOnlyBasicRepository repository, CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
+ [Obsolete("Use GetQueryableAsync method.")]
+ public static Task> GetMongoQueryableAsync(this IReadOnlyBasicRepository repository, CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
where TEntity : class, IEntity
{
return repository.ToMongoDbRepository().GetMongoQueryableAsync(cancellationToken, aggregateOptions);
}
+ public static Task> GetQueryableAsync(this IReadOnlyBasicRepository repository)
+ where TEntity : class, IEntity
+ {
+ return repository.ToMongoDbRepository().GetQueryableAsync();
+ }
+
public static Task> GetAggregateAsync(this IReadOnlyBasicRepository repository, CancellationToken cancellationToken = default, AggregateOptions? aggregateOptions = null)
where TEntity : class, IEntity
{
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbDateTimeSerializer.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbDateTimeSerializer.cs
index c1d8b8f514..6ad2b0b359 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbDateTimeSerializer.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbDateTimeSerializer.cs
@@ -5,7 +5,7 @@ using MongoDB.Bson.Serialization.Serializers;
namespace Volo.Abp.MongoDB;
-public class AbpMongoDbDateTimeSerializer : DateTimeSerializer
+public class AbpMongoDbDateTimeSerializer : StructSerializerBase
{
protected DateTimeKind DateTimeKind { get; set; }
protected bool DisableDateTimeNormalization { get; set; }
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs
index f61e9ddb45..91d2808010 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/AbpMongoDbModule.cs
@@ -1,5 +1,8 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
+using MongoDB.Bson;
+using MongoDB.Bson.Serialization;
+using MongoDB.Bson.Serialization.Serializers;
using Volo.Abp.Domain;
using Volo.Abp.Domain.Repositories.MongoDB;
using Volo.Abp.Modularity;
@@ -19,6 +22,8 @@ public class AbpMongoDbModule : AbpModule
public override void ConfigureServices(ServiceConfigurationContext context)
{
+ BsonSerializer.TryRegisterSerializer(new GuidSerializer(GuidRepresentation.Standard));
+
context.Services.TryAddTransient(
typeof(IMongoDbContextProvider<>),
typeof(UnitOfWorkMongoDbContextProvider<>)
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs
index 6a73af27f5..9d1b706d8b 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventInbox.cs
@@ -68,7 +68,6 @@ public class MongoDbContextEventInbox : IMongoDbContextEventInb
.WhereIf(transformedFilter != null, transformedFilter!)
.OrderBy(x => x.CreationTime)
.Take(maxCount)
- .As>()
.ToListAsync(cancellationToken: cancellationToken);
return outgoingEventRecords
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventOutbox.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventOutbox.cs
index 57b59038b5..6dc8817f02 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventOutbox.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/DistributedEvents/MongoDbContextEventOutbox.cs
@@ -56,7 +56,6 @@ public class MongoDbContextEventOutbox : IMongoDbContextEventOu
.WhereIf(transformedFilter != null, transformedFilter!)
.OrderBy(x => x.CreationTime)
.Take(maxCount)
- .As>()
.ToListAsync(cancellationToken: cancellationToken);
return outgoingEventRecords
diff --git a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs
index 287f3ced0e..b7e896a27a 100644
--- a/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs
+++ b/framework/src/Volo.Abp.MongoDB/Volo/Abp/MongoDB/MongoDbAsyncQueryableProvider.cs
@@ -6,9 +6,7 @@ using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Linq;
-using MongoDB.Driver;
using MongoDB.Driver.Linq;
-using Volo.Abp.DynamicProxy;
namespace Volo.Abp.MongoDB;
@@ -16,344 +14,339 @@ public class MongoDbAsyncQueryableProvider : IAsyncQueryableProvider, ISingleton
{
public bool CanExecute(IQueryable queryable)
{
- return ProxyHelper.UnProxy(queryable) is IMongoQueryable;
- }
-
- protected virtual IMongoQueryable GetMongoQueryable(IQueryable queryable)
- {
- return ProxyHelper.UnProxy(queryable).As>();
+ return queryable.Provider is IMongoQueryProvider;
}
public Task ContainsAsync(IQueryable queryable, T item, CancellationToken cancellationToken = default)
{
- return Task.FromResult(GetMongoQueryable(queryable).Contains(item));
+ return Task.FromResult(queryable.Contains(item));
}
public Task AnyAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).AnyAsync(cancellationToken);
+ return queryable.AnyAsync(cancellationToken);
}
public Task AnyAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).AnyAsync(predicate, cancellationToken);
+ return queryable.AnyAsync(predicate, cancellationToken);
}
public Task AllAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return Task.FromResult(GetMongoQueryable(queryable).All(predicate));
+ return Task.FromResult(queryable.All(predicate));
}
public Task CountAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).CountAsync(cancellationToken);
+ return queryable.CountAsync(cancellationToken);
}
public Task CountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).CountAsync(predicate, cancellationToken);
+ return queryable.CountAsync(predicate, cancellationToken);
}
public Task LongCountAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).LongCountAsync(cancellationToken);
+ return queryable.LongCountAsync(cancellationToken);
}
public Task LongCountAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).LongCountAsync(predicate, cancellationToken);
+ return queryable.LongCountAsync(predicate, cancellationToken);
}
public Task FirstAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).FirstAsync(cancellationToken);
+ return queryable.FirstAsync(cancellationToken);
}
public Task FirstAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).FirstAsync(predicate, cancellationToken);
+ return queryable.FirstAsync(predicate, cancellationToken);
}
public Task FirstOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).FirstOrDefaultAsync(cancellationToken)!;
+ return queryable.FirstOrDefaultAsync(cancellationToken)!;
}
public Task FirstOrDefaultAsync(IQueryable queryable, Expression> predicate,
CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).FirstOrDefaultAsync(predicate, cancellationToken)!;
+ return queryable.FirstOrDefaultAsync(predicate, cancellationToken)!;
}
public Task LastAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return Task.FromResult(GetMongoQueryable(queryable).Last());
+ return Task.FromResult(queryable.Last());
}
public Task LastAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return Task.FromResult(GetMongoQueryable(queryable).Last(predicate));
+ return Task.FromResult(queryable.Last(predicate));
}
public Task LastOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return Task.FromResult(GetMongoQueryable(queryable).LastOrDefault());
+ return Task.FromResult(queryable.LastOrDefault());
}
public Task LastOrDefaultAsync(IQueryable queryable, Expression> predicate,
CancellationToken cancellationToken = default)
{
- return Task.FromResult(GetMongoQueryable(queryable).LastOrDefault(predicate));
+ return Task.FromResult(queryable.LastOrDefault(predicate));
}
public Task SingleAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SingleAsync(cancellationToken);
+ return queryable.SingleAsync(cancellationToken);
}
public Task SingleAsync(IQueryable queryable, Expression> predicate, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SingleAsync(predicate, cancellationToken);
+ return queryable.SingleAsync(predicate, cancellationToken);
}
public Task SingleOrDefaultAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SingleOrDefaultAsync(cancellationToken)!;
+ return queryable.SingleOrDefaultAsync(cancellationToken)!;
}
public Task SingleOrDefaultAsync(IQueryable queryable, Expression> predicate,
CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SingleOrDefaultAsync(predicate, cancellationToken)!;
+ return queryable.SingleOrDefaultAsync(predicate, cancellationToken)!;
}
public Task MinAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).MinAsync(cancellationToken);
+ return queryable.MinAsync(cancellationToken);
}
public Task MinAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).MinAsync(selector, cancellationToken);
+ return queryable.MinAsync(selector, cancellationToken);
}
public Task MaxAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).MaxAsync(cancellationToken);
+ return queryable.MaxAsync(cancellationToken);
}
public Task MaxAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).MaxAsync(selector, cancellationToken);
+ return queryable.MaxAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(cancellationToken);
+ return queryable.SumAsync(cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task SumAsync(IQueryable queryable, Expression> selector, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).SumAsync(selector, cancellationToken);
+ return queryable.SumAsync(selector, cancellationToken);
}
public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).AverageAsync(cancellationToken);
+ return queryable.AverageAsync(cancellationToken);
}
public Task AverageAsync(IQueryable queryable, CancellationToken cancellationToken = default)
{
- return GetMongoQueryable(queryable).AverageAsync(cancellationToken);
+ return queryable.AverageAsync(cancellationToken);
}
public Task AverageAsync(IQueryable