Skip to content

Conversation

fiseni
Copy link
Collaborator

@fiseni fiseni commented Jun 18, 2022

Closes #242. Refer to the related issue for more details.

  • Added the ISingleResultSpecification<T, TResult> interface.
  public interface ISingleResultSpecification
  {
  }
  public interface ISingleResultSpecification<T> : ISpecification<T>, ISingleResultSpecification
  {
  }
  public interface ISingleResultSpecification<T, TResult> : ISpecification<T, TResult>, ISingleResultSpecification
  {
  }
  • Added the SingleResultSpecification base classes for convenience.
  public class SingleResultSpecification<T> : Specification<T>, ISingleResultSpecification<T>
  {
  }
  public class SingleResultSpecification<T, TResult> : Specification<T, TResult>, ISingleResultSpecification<T, TResult>
  {
  }
  • Removed the constraints for GetBySpec repository method. Marked these methods as obsolete.
  [Obsolete]
  Task<T?> GetBySpecAsync(ISpecification<T> specification, CancellationToken cancellationToken = default);

  [Obsolete]
  Task<TResult?> GetBySpecAsync<TResult>(ISpecification<T, TResult> specification, CancellationToken cancellationToken = default);
  • Added verbose repository methods.
  // These will work with any specification.
  Task<T?> FirstOrDefaultAsync(ISpecification<T> specification, CancellationToken cancellationToken = default);
  Task<TResult?> FirstOrDefaultAsync<TResult>(ISpecification<T, TResult> specification, CancellationToken cancellationToken = default);

  // These will work only with SingleResultSpecification 
  Task<T?> SingleOrDefaultAsync(ISingleResultSpecification<T> specification, CancellationToken cancellationToken = default);
  Task<TResult?> SingleOrDefaultAsync<TResult>(ISingleResultSpecification<T, TResult> specification, CancellationToken cancellationToken = default);
  • Added UpdateRangeAsync repository method (community request).
  Task UpdateRangeAsync(IEnumerable<T> entities, CancellationToken cancellationToken = default);

@fiseni fiseni requested a review from ardalis June 21, 2022 20:24
@ardalis
Copy link
Owner

ardalis commented Jun 23, 2022

Looks great!

@davidhenley
Copy link
Contributor

Does this mean GetBySpecAsync should be replaced with First/SingleOrDefaultAsync?

Just making sure as it's not stated anywhere in the release notes

@ardalis
Copy link
Owner

ardalis commented Aug 2, 2022

Yes, and I'll try and get the release notes updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISingleResultSpecification usage issue.

3 participants