net8, language features, bugfixes
This commit is contained in:
parent
1591618c2c
commit
ce99053a10
353 changed files with 3245 additions and 3944 deletions
|
|
@ -0,0 +1,44 @@
|
|||
using Insight.Infrastructure.Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace Insight.Infrastructure.Web;
|
||||
|
||||
public static class MongoCollectionExtensions
|
||||
{
|
||||
public static async Task<PagedList<TData>> GetPagedAsync<TData>(
|
||||
this IMongoCollection<TData> collection,
|
||||
HttpRequest request,
|
||||
HttpResponse response,
|
||||
FilterDefinition<TData>? filter = null,
|
||||
SortDefinition<TData>? sort = null,
|
||||
int offset = 0,
|
||||
int limit = 10,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await Infrastructure.MongoCollectionExtensions.GetPagedAsync(collection, filter, sort, offset, limit, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
request?.AddPagination(result);
|
||||
response?.AddPagination(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<PagedList<TResult>> GetPagedAsync<TData, TResult>(
|
||||
this IMongoCollection<TData> collection,
|
||||
HttpRequest request,
|
||||
HttpResponse response,
|
||||
IAggregateFluent<BsonDocument> query,
|
||||
int offset = 0,
|
||||
int limit = 10,
|
||||
CancellationToken cancellationToken = default)
|
||||
{
|
||||
var result = await Infrastructure.MongoCollectionExtensions.GetPagedAsync<TData, TResult>(collection, query, offset, limit, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
request?.AddPagination(result);
|
||||
response?.AddPagination(result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue