diff --git a/Interfaces/IXBaseRepository.cs b/Interfaces/IXBaseRepository.cs index 28befdd..e9b0fc5 100644 --- a/Interfaces/IXBaseRepository.cs +++ b/Interfaces/IXBaseRepository.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.Query; diff --git a/Interfaces/IXBaseRepositoryService.cs b/Interfaces/IXBaseRepositoryService.cs index 0aaea60..22f1ea3 100644 --- a/Interfaces/IXBaseRepositoryService.cs +++ b/Interfaces/IXBaseRepositoryService.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using AutoMapper; @@ -227,6 +228,22 @@ namespace xDataService.Interfaces CancellationToken cancellationToken = default ); + /// + /// retrieve all exists Dtos + /// as Async Enumerable ... + /// + /// + /// + /// + /// + /// + IAsyncEnumerable GetAllAsAsyncEnumerable( + bool ignoreSoftDeleteds = true, + Func, IOrderedQueryable> orderBuilder = null, + Func, IIncludableQueryable> includeBuilder = null, + CancellationToken cancellationToken = default + ); + /// /// find an Dto by providing a Conditional Expression ... /// diff --git a/Providers/XBaseEFRepository.cs b/Providers/XBaseEFRepository.cs index 6617307..b1defd0 100644 --- a/Providers/XBaseEFRepository.cs +++ b/Providers/XBaseEFRepository.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore; diff --git a/Providers/XBaseRepositoryService.cs b/Providers/XBaseRepositoryService.cs index 15def43..2233b4a 100644 --- a/Providers/XBaseRepositoryService.cs +++ b/Providers/XBaseRepositoryService.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; +using System.Runtime.CompilerServices; using System.Threading; using System.Threading.Tasks; using AutoMapper; @@ -613,6 +614,42 @@ namespace xDataService.Providers return result; } + /// + /// retrieve all exists Dtos + /// as Async Enumerable ... + /// + /// + /// + /// + /// + /// + public async IAsyncEnumerable GetAllAsAsyncEnumerable( + bool ignoreSoftDeleteds = true, + Func, IOrderedQueryable> orderBuilder = null, + Func, IIncludableQueryable> includeBuilder = null, + [EnumeratorCancellation] CancellationToken cancellationToken = default + ) + { + // + var entityEnumerable = Repository.GetAllAsAsyncEnumerable( + orderBuilder: orderBuilder, + includeBuilder: includeBuilder, + ignoreSoftDeleteds: ignoreSoftDeleteds + ); + await foreach (var entity in entityEnumerable) + { + // + if (cancellationToken.IsCancellationRequested) + { + yield break; + } + + // + var dto = Mapper.Map(entity); + yield return dto; + } + } + /// /// find an Dto by providing a Conditional Expression ... /// diff --git a/xDataService.csproj b/xDataService.csproj index 42e40fd..0dc3763 100644 --- a/xDataService.csproj +++ b/xDataService.csproj @@ -7,6 +7,7 @@ SaherElm IT Center xDashboard.xDataService netstandard2.0 + provide base requiremennts for Repository DataBase using and tools for using in xDashboard project.