diff --git a/README.md b/README.md index 23f1626f..13d4abfa 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ Example implementation in your repository using specifications ```c# public async Task> ListAsync(ISpecification specification, CancellationToken cancellationToken = default) { - var query = SpecificationEvaluator.GetQuery(DbContext.Set(), specification); + var query = SpecificationEvaluator.Default.GetQuery(_dbContext.Set(), specification); return await query.ToListAsync(cancellationToken); } ``` diff --git a/src/Ardalis.Specification.EntityFramework6/Ardalis.Specification.EntityFramework6.csproj b/src/Ardalis.Specification.EntityFramework6/Ardalis.Specification.EntityFramework6.csproj index 9fd25001..66bb0e4f 100644 --- a/src/Ardalis.Specification.EntityFramework6/Ardalis.Specification.EntityFramework6.csproj +++ b/src/Ardalis.Specification.EntityFramework6/Ardalis.Specification.EntityFramework6.csproj @@ -11,10 +11,11 @@ EF6 plugin package to Ardalis.Specification containing EF6 evaluator and abstract repository. EF6 plugin package to Ardalis.Specification containing EF6 evaluator and abstract repository. - 8.0.0 + 9.0.0 spec;specification;repository;ddd;ef;ef6;entity framework - * Added TFM for net6.0 + The change log and breaking changes are listed here. + https://github.com/ardalis/Specification/issues/427 diff --git a/src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs b/src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs index 614bdacb..c6c46829 100644 --- a/src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs +++ b/src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs @@ -171,7 +171,7 @@ public virtual async Task AnyAsync(CancellationToken cancellationToken = d return await DbContext.Set().AnyAsync(cancellationToken); } -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER /// public virtual IAsyncEnumerable AsAsyncEnumerable(ISpecification specification) { @@ -184,6 +184,7 @@ public virtual IAsyncEnumerable AsAsyncEnumerable(ISpecification specifica /// . /// /// The encapsulated query logic. + /// It ignores pagination and evaluators that don't affect Count. /// The filtered entities as an . protected virtual IQueryable ApplySpecification(ISpecification specification, bool evaluateCriteriaOnly = false) { diff --git a/src/Ardalis.Specification.EntityFrameworkCore/Ardalis.Specification.EntityFrameworkCore.csproj b/src/Ardalis.Specification.EntityFrameworkCore/Ardalis.Specification.EntityFrameworkCore.csproj index a4a0eb92..db19fc9d 100644 --- a/src/Ardalis.Specification.EntityFrameworkCore/Ardalis.Specification.EntityFrameworkCore.csproj +++ b/src/Ardalis.Specification.EntityFrameworkCore/Ardalis.Specification.EntityFrameworkCore.csproj @@ -10,10 +10,11 @@ EF Core plugin package to Ardalis.Specification containing EF Core evaluator and abstract repository. EF Core plugin package to Ardalis.Specification containing EF Core evaluator and abstract repository. - 8.0.0 + 9.0.0 spec;specification;repository;ddd;ef;ef core;entity framework;entity framework core - * Added TFMs net6.0, net7.0 and net8.0 + The change log and breaking changes are listed here. + https://github.com/ardalis/Specification/issues/427 diff --git a/src/Ardalis.Specification.EntityFrameworkCore/ContextFactoryRepositoryBaseOfT.cs b/src/Ardalis.Specification.EntityFrameworkCore/ContextFactoryRepositoryBaseOfT.cs index bfffea09..e50be38b 100644 --- a/src/Ardalis.Specification.EntityFrameworkCore/ContextFactoryRepositoryBaseOfT.cs +++ b/src/Ardalis.Specification.EntityFrameworkCore/ContextFactoryRepositoryBaseOfT.cs @@ -204,6 +204,8 @@ public async Task SaveChangesAsync(TContext dbContext, CancellationToken ca /// . /// /// The encapsulated query logic. + /// The DbContext instance. + /// It ignores pagination and evaluators that don't affect Count. /// The filtered entities as an . protected virtual IQueryable ApplySpecification(ISpecification specification, TContext dbContext, bool evaluateCriteriaOnly = false) { @@ -219,6 +221,7 @@ protected virtual IQueryable ApplySpecification(ISpecification /// /// The type of the value returned by the projection. /// The encapsulated query logic. + /// The DbContext instance. /// The filtered projected entities as an . protected virtual IQueryable ApplySpecification(ISpecification specification, TContext dbContext) { diff --git a/src/Ardalis.Specification.EntityFrameworkCore/RepositoryBaseOfT.cs b/src/Ardalis.Specification.EntityFrameworkCore/RepositoryBaseOfT.cs index a7961709..9dde0544 100644 --- a/src/Ardalis.Specification.EntityFrameworkCore/RepositoryBaseOfT.cs +++ b/src/Ardalis.Specification.EntityFrameworkCore/RepositoryBaseOfT.cs @@ -177,6 +177,7 @@ public virtual IAsyncEnumerable AsAsyncEnumerable(ISpecification specifica /// . /// /// The encapsulated query logic. + /// It ignores pagination and evaluators that don't affect Count. /// The filtered entities as an . protected virtual IQueryable ApplySpecification(ISpecification specification, bool evaluateCriteriaOnly = false) { diff --git a/src/Ardalis.Specification/Ardalis.Specification.csproj b/src/Ardalis.Specification/Ardalis.Specification.csproj index 02bed858..59ca0925 100644 --- a/src/Ardalis.Specification/Ardalis.Specification.csproj +++ b/src/Ardalis.Specification/Ardalis.Specification.csproj @@ -10,10 +10,11 @@ A simple package with a base Specification class, for use in creating queries that work with Repository types. A simple package with a base Specification class, for use in creating queries that work with Repository types. - 8.0.0 + 9.0.0 spec;specification;repository;ddd - * Added TFMs net6.0, net7.0 and net8.0 + The change log and breaking changes are listed here. + https://github.com/ardalis/Specification/issues/427 diff --git a/src/Ardalis.Specification/Evaluators/ISpecificationEvaluator.cs b/src/Ardalis.Specification/Evaluators/ISpecificationEvaluator.cs index 732cbc6a..5dbdc940 100644 --- a/src/Ardalis.Specification/Evaluators/ISpecificationEvaluator.cs +++ b/src/Ardalis.Specification/Evaluators/ISpecificationEvaluator.cs @@ -9,6 +9,7 @@ public interface ISpecificationEvaluator /// Applies the logic encapsulated by to given , /// and projects the result into . /// + /// The type of the entity. /// The type of the result. /// The sequence of /// The encapsulated query logic. @@ -17,8 +18,10 @@ public interface ISpecificationEvaluator /// /// Applies the logic encapsulated by to given . /// + /// The type of the entity. /// The sequence of /// The encapsulated query logic. + /// It ignores pagination and evaluators that don't affect Count. /// A filtered sequence of IQueryable GetQuery(IQueryable inputQuery, ISpecification specification, bool evaluateCriteriaOnly = false) where T : class; } diff --git a/src/Ardalis.Specification/IEntity.cs b/src/Ardalis.Specification/IEntity.cs deleted file mode 100644 index 464d6291..00000000 --- a/src/Ardalis.Specification/IEntity.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Ardalis.Specification; - -public interface IEntity -{ - TId Id { get; set; } -} diff --git a/src/Ardalis.Specification/IReadRepositoryBase.cs b/src/Ardalis.Specification/IReadRepositoryBase.cs index c83a43b8..48a5f35f 100644 --- a/src/Ardalis.Specification/IReadRepositoryBase.cs +++ b/src/Ardalis.Specification/IReadRepositoryBase.cs @@ -14,7 +14,7 @@ public interface IReadRepositoryBase where T : class /// /// The type of primary key. /// The value of the primary key for the entity to be found. - /// + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains the , or . @@ -25,7 +25,7 @@ public interface IReadRepositoryBase where T : class /// Returns the first element of a sequence, or a default value if the sequence contains no elements. /// /// The encapsulated query logic. - /// A to observe while waiting for the task to complete. + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains the , or . @@ -36,7 +36,7 @@ public interface IReadRepositoryBase where T : class /// Returns the first element of a sequence, or a default value if the sequence contains no elements. /// /// The encapsulated query logic. - /// A to observe while waiting for the task to complete. + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains the , or . @@ -47,7 +47,7 @@ public interface IReadRepositoryBase where T : class /// Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. /// /// The encapsulated query logic. - /// A to observe while waiting for the task to complete. + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains the , or . @@ -58,7 +58,7 @@ public interface IReadRepositoryBase where T : class /// Returns the only element of a sequence, or a default value if the sequence is empty; this method throws an exception if there is more than one element in the sequence. /// /// The encapsulated query logic. - /// A to observe while waiting for the task to complete. + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains the , or . @@ -68,6 +68,7 @@ public interface IReadRepositoryBase where T : class /// /// Finds all entities of from the database. /// + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains a that contains elements from the input sequence. @@ -79,6 +80,7 @@ public interface IReadRepositoryBase where T : class /// , from the database. /// /// The encapsulated query logic. + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains a that contains elements from the input sequence. @@ -94,6 +96,7 @@ public interface IReadRepositoryBase where T : class /// /// The type of the value returned by the projection. /// The encapsulated query logic. + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains a that contains elements from the input sequence. @@ -105,6 +108,7 @@ public interface IReadRepositoryBase where T : class /// of the . /// /// The encapsulated query logic. + /// The cancellation token. /// /// A task that represents the asynchronous operation. The task result contains the /// number of elements in the input sequence. @@ -114,6 +118,7 @@ public interface IReadRepositoryBase where T : class /// /// Returns the total number of records. /// + /// The cancellation token. /// /// A task that represents the asynchronous operation. The task result contains the /// number of elements in the input sequence. @@ -125,6 +130,7 @@ public interface IReadRepositoryBase where T : class /// of the or not. /// /// The encapsulated query logic. + /// The cancellation token. /// /// A task that represents the asynchronous operation. The task result contains true if the /// source sequence contains any elements; otherwise, false. @@ -134,6 +140,7 @@ public interface IReadRepositoryBase where T : class /// /// Returns a boolean whether any entity exists or not. /// + /// The cancellation token. /// /// A task that represents the asynchronous operation. The task result contains true if the /// source sequence contains any elements; otherwise, false. @@ -141,7 +148,7 @@ public interface IReadRepositoryBase where T : class Task AnyAsync(CancellationToken cancellationToken = default); -#if NET6_0_OR_GREATER +#if NET8_0_OR_GREATER /// /// Finds all entities of , that matches the encapsulated query logic of the /// , from the database. diff --git a/src/Ardalis.Specification/IRepositoryBase.cs b/src/Ardalis.Specification/IRepositoryBase.cs index e5148250..0450e70f 100644 --- a/src/Ardalis.Specification/IRepositoryBase.cs +++ b/src/Ardalis.Specification/IRepositoryBase.cs @@ -14,7 +14,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// Adds an entity in the database. /// /// The entity to add. - /// + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// The task result contains the . @@ -25,7 +25,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// Adds the given entities in the database /// /// - /// + /// The cancellation token. /// /// A task that represents the asynchronous operation. /// @@ -35,6 +35,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// Updates an entity in the database /// /// The entity to update. + /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the number of state entries written to the database. Task UpdateAsync(T entity, CancellationToken cancellationToken = default); @@ -42,7 +43,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// Updates the given entities in the database /// /// The entities to update. - /// + /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the number of state entries written to the database. Task UpdateRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default); @@ -50,6 +51,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// Removes an entity in the database /// /// The entity to delete. + /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the number of state entries written to the database. Task DeleteAsync(T entity, CancellationToken cancellationToken = default); @@ -57,6 +59,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// Removes the given entities in the database /// /// The entities to remove. + /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the number of state entries written to the database. Task DeleteRangeAsync(IEnumerable entities, CancellationToken cancellationToken = default); @@ -65,6 +68,7 @@ public interface IRepositoryBase : IReadRepositoryBase where T : class /// , from the database. /// /// The encapsulated query logic. + /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the number of state entries written to the database. Task DeleteRangeAsync(ISpecification specification, CancellationToken cancellationToken = default); diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 93e4dbd4..78eae77d 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -31,7 +31,8 @@ - 1701;1702;1591;1573;1712 + + 1591 diff --git a/tests/Ardalis.Specification.EntityFrameworkCore.Tests/Repositories/Repository_WriteTests.cs b/tests/Ardalis.Specification.EntityFrameworkCore.Tests/Repositories/Repository_WriteTests.cs index ffdbc73f..eff772b7 100644 --- a/tests/Ardalis.Specification.EntityFrameworkCore.Tests/Repositories/Repository_WriteTests.cs +++ b/tests/Ardalis.Specification.EntityFrameworkCore.Tests/Repositories/Repository_WriteTests.cs @@ -139,7 +139,7 @@ public async Task DeleteRangeAsync_ShouldDeleteEntitiesBySpec() await SeedRangeAsync(countries); var spec = new Specification(); - spec.Query.Where(x=>x.Name == guid); + spec.Query.Where(x => x.Name == guid); await repo.DeleteRangeAsync(spec); DbContext.ChangeTracker.Clear(); diff --git a/tests/Directory.Build.props b/tests/Directory.Build.props index ac69d253..a24d674d 100644 --- a/tests/Directory.Build.props +++ b/tests/Directory.Build.props @@ -23,7 +23,4 @@ - - 1701;1702;1591;1573;1712;0618 - - \ No newline at end of file +