@@ -8,7 +8,11 @@ namespace Ardalis.Specification.EntityFrameworkCore
88{
99 public static class DbSetExtensions
1010 {
11- public static async Task < List < TSource > > ToListAsync < TSource > ( this DbSet < TSource > source , ISpecification < TSource > specification , CancellationToken cancellationToken = default ) where TSource : class
11+ public static async Task < List < TSource > > ToListAsync < TSource > (
12+ this DbSet < TSource > source ,
13+ ISpecification < TSource > specification ,
14+ CancellationToken cancellationToken = default )
15+ where TSource : class
1216 {
1317 var result = await SpecificationEvaluator . Default . GetQuery ( source , specification ) . ToListAsync ( cancellationToken ) ;
1418
@@ -17,7 +21,11 @@ public static async Task<List<TSource>> ToListAsync<TSource>(this DbSet<TSource>
1721 : specification . PostProcessingAction ( result ) . ToList ( ) ;
1822 }
1923
20- public static async Task < IEnumerable < TSource > > ToEnumerableAsync < TSource > ( this DbSet < TSource > source , ISpecification < TSource > specification , CancellationToken cancellationToken = default ) where TSource : class
24+ public static async Task < IEnumerable < TSource > > ToEnumerableAsync < TSource > (
25+ this DbSet < TSource > source ,
26+ ISpecification < TSource > specification ,
27+ CancellationToken cancellationToken = default )
28+ where TSource : class
2129 {
2230 var result = await SpecificationEvaluator . Default . GetQuery ( source , specification ) . ToListAsync ( cancellationToken ) ;
2331
@@ -26,7 +34,21 @@ public static async Task<IEnumerable<TSource>> ToEnumerableAsync<TSource>(this D
2634 : specification . PostProcessingAction ( result ) ;
2735 }
2836
29- public static IQueryable < TSource > WithSpecification < TSource > ( this IQueryable < TSource > source , ISpecification < TSource > specification , ISpecificationEvaluator ? evaluator = null ) where TSource : class
37+ public static IQueryable < TSource > WithSpecification < TSource > (
38+ this IQueryable < TSource > source ,
39+ ISpecification < TSource > specification ,
40+ ISpecificationEvaluator ? evaluator = null )
41+ where TSource : class
42+ {
43+ evaluator = evaluator ?? SpecificationEvaluator . Default ;
44+ return evaluator . GetQuery ( source , specification ) ;
45+ }
46+
47+ public static IQueryable < TResult > WithSpecification < TSource , TResult > (
48+ this IQueryable < TSource > source ,
49+ ISpecification < TSource , TResult > specification ,
50+ ISpecificationEvaluator ? evaluator = null )
51+ where TSource : class
3052 {
3153 evaluator = evaluator ?? SpecificationEvaluator . Default ;
3254 return evaluator . GetQuery ( source , specification ) ;
0 commit comments