diff --git a/Specification.EntityFramework6/src/Ardalis.Specification.EntityFramework6/Extensions/DbSetExtensions.cs b/Specification.EntityFramework6/src/Ardalis.Specification.EntityFramework6/Extensions/DbSetExtensions.cs index 7ae435a3..03497123 100644 --- a/Specification.EntityFramework6/src/Ardalis.Specification.EntityFramework6/Extensions/DbSetExtensions.cs +++ b/Specification.EntityFramework6/src/Ardalis.Specification.EntityFramework6/Extensions/DbSetExtensions.cs @@ -8,7 +8,11 @@ namespace Ardalis.Specification.EntityFramework6 { public static class DbSetExtensions { - public static async Task> ToListAsync(this DbSet source, ISpecification specification, CancellationToken cancellationToken = default) where TSource : class + public static async Task> ToListAsync( + this DbSet source, + ISpecification specification, + CancellationToken cancellationToken = default) + where TSource : class { var result = await SpecificationEvaluator.Default.GetQuery(source, specification).ToListAsync(cancellationToken); @@ -17,7 +21,11 @@ public static async Task> ToListAsync(this DbSet : specification.PostProcessingAction(result).ToList(); } - public static async Task> ToEnumerableAsync(this DbSet source, ISpecification specification, CancellationToken cancellationToken = default) where TSource : class + public static async Task> ToEnumerableAsync( + this DbSet source, + ISpecification specification, + CancellationToken cancellationToken = default) + where TSource : class { var result = await SpecificationEvaluator.Default.GetQuery(source, specification).ToListAsync(cancellationToken); @@ -26,7 +34,21 @@ public static async Task> ToEnumerableAsync(this D : specification.PostProcessingAction(result); } - public static IQueryable WithSpecification(this IQueryable source, ISpecification specification, ISpecificationEvaluator evaluator = null) where TSource : class + public static IQueryable WithSpecification( + this IQueryable source, + ISpecification specification, + ISpecificationEvaluator evaluator = null) + where TSource : class + { + evaluator = evaluator ?? SpecificationEvaluator.Default; + return evaluator.GetQuery(source, specification); + } + + public static IQueryable WithSpecification( + this IQueryable source, + ISpecification specification, + ISpecificationEvaluator evaluator = null) + where TSource : class { evaluator = evaluator ?? SpecificationEvaluator.Default; return evaluator.GetQuery(source, specification); diff --git a/Specification.EntityFrameworkCore/src/Ardalis.Specification.EntityFrameworkCore/Extensions/DbSetExtensions.cs b/Specification.EntityFrameworkCore/src/Ardalis.Specification.EntityFrameworkCore/Extensions/DbSetExtensions.cs index c27133f4..ed13f61a 100644 --- a/Specification.EntityFrameworkCore/src/Ardalis.Specification.EntityFrameworkCore/Extensions/DbSetExtensions.cs +++ b/Specification.EntityFrameworkCore/src/Ardalis.Specification.EntityFrameworkCore/Extensions/DbSetExtensions.cs @@ -8,7 +8,11 @@ namespace Ardalis.Specification.EntityFrameworkCore { public static class DbSetExtensions { - public static async Task> ToListAsync(this DbSet source, ISpecification specification, CancellationToken cancellationToken = default) where TSource : class + public static async Task> ToListAsync( + this DbSet source, + ISpecification specification, + CancellationToken cancellationToken = default) + where TSource : class { var result = await SpecificationEvaluator.Default.GetQuery(source, specification).ToListAsync(cancellationToken); @@ -17,7 +21,11 @@ public static async Task> ToListAsync(this DbSet : specification.PostProcessingAction(result).ToList(); } - public static async Task> ToEnumerableAsync(this DbSet source, ISpecification specification, CancellationToken cancellationToken = default) where TSource : class + public static async Task> ToEnumerableAsync( + this DbSet source, + ISpecification specification, + CancellationToken cancellationToken = default) + where TSource : class { var result = await SpecificationEvaluator.Default.GetQuery(source, specification).ToListAsync(cancellationToken); @@ -26,7 +34,21 @@ public static async Task> ToEnumerableAsync(this D : specification.PostProcessingAction(result); } - public static IQueryable WithSpecification(this IQueryable source, ISpecification specification, ISpecificationEvaluator? evaluator = null) where TSource : class + public static IQueryable WithSpecification( + this IQueryable source, + ISpecification specification, + ISpecificationEvaluator? evaluator = null) + where TSource : class + { + evaluator = evaluator ?? SpecificationEvaluator.Default; + return evaluator.GetQuery(source, specification); + } + + public static IQueryable WithSpecification( + this IQueryable source, + ISpecification specification, + ISpecificationEvaluator? evaluator = null) + where TSource : class { evaluator = evaluator ?? SpecificationEvaluator.Default; return evaluator.GetQuery(source, specification);