Skip to content

Commit fab04ee

Browse files
authored
Add messages to obsolete specs for clarity (#373)
* Add messages to obsolete specs for clarity * Update messages to be more straightforward & concise
1 parent a2698eb commit fab04ee

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Specification.EntityFramework6/src/Ardalis.Specification.EntityFramework6/RepositoryBaseOfT.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,14 @@ public virtual async Task<T> GetByIdAsync<TId>(TId id, CancellationToken cancell
102102
}
103103

104104
/// <inheritdoc/>
105-
[Obsolete]
105+
[Obsolete("Use FirstOrDefaultAsync<T> or SingleOrDefaultAsync<T> instead. The SingleOrDefaultAsync<T> can be applied only to SingleResultSpecification<T> specifications.")]
106106
public virtual async Task<T> GetBySpecAsync(ISpecification<T> specification, CancellationToken cancellationToken = default)
107107
{
108108
return await ApplySpecification(specification).FirstOrDefaultAsync(cancellationToken);
109109
}
110110

111111
/// <inheritdoc/>
112-
[Obsolete]
112+
[Obsolete("Use FirstOrDefaultAsync<T> or SingleOrDefaultAsync<T> instead. The SingleOrDefaultAsync<T> can be applied only to SingleResultSpecification<T> specifications.")]
113113
public virtual async Task<TResult> GetBySpecAsync<TResult>(ISpecification<T, TResult> specification, CancellationToken cancellationToken = default)
114114
{
115115
return await ApplySpecification(specification).FirstOrDefaultAsync(cancellationToken);

Specification.EntityFrameworkCore/src/Ardalis.Specification.EntityFrameworkCore/RepositoryBaseOfT.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ public virtual async Task<int> SaveChangesAsync(CancellationToken cancellationTo
9494
}
9595

9696
/// <inheritdoc/>
97-
[Obsolete]
97+
[Obsolete("Use FirstOrDefaultAsync<T> or SingleOrDefaultAsync<T> instead. The SingleOrDefaultAsync<T> can be applied only to SingleResultSpecification<T> specifications.")]
9898
public virtual async Task<T?> GetBySpecAsync(ISpecification<T> specification, CancellationToken cancellationToken = default)
9999
{
100100
return await ApplySpecification(specification).FirstOrDefaultAsync(cancellationToken);
101101
}
102102

103103
/// <inheritdoc/>
104-
[Obsolete]
104+
[Obsolete("Use FirstOrDefaultAsync<T> or SingleOrDefaultAsync<T> instead. The SingleOrDefaultAsync<T> can be applied only to SingleResultSpecification<T> specifications.")]
105105
public virtual async Task<TResult?> GetBySpecAsync<TResult>(ISpecification<T, TResult> specification, CancellationToken cancellationToken = default)
106106
{
107107
return await ApplySpecification(specification).FirstOrDefaultAsync(cancellationToken);

Specification/src/Ardalis.Specification/IReadRepositoryBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public interface IReadRepositoryBase<T> where T : class
3434
/// A task that represents the asynchronous operation.
3535
/// The task result contains the <typeparamref name="T" />, or <see langword="null"/>.
3636
/// </returns>
37-
[Obsolete]
37+
[Obsolete("Use FirstOrDefaultAsync<T> or SingleOrDefaultAsync<T> instead. The SingleOrDefaultAsync<T> can be applied only to SingleResultSpecification<T> specifications.")]
3838
Task<T?> GetBySpecAsync(ISpecification<T> specification, CancellationToken cancellationToken = default);
3939

4040
/// <summary>
@@ -46,7 +46,7 @@ public interface IReadRepositoryBase<T> where T : class
4646
/// A task that represents the asynchronous operation.
4747
/// The task result contains the <typeparamref name="TResult" />.
4848
/// </returns>
49-
[Obsolete]
49+
[Obsolete("Use FirstOrDefaultAsync<T> or SingleOrDefaultAsync<T> instead. The SingleOrDefaultAsync<T> can be applied only to SingleResultSpecification<T> specifications.")]
5050
Task<TResult?> GetBySpecAsync<TResult>(ISpecification<T, TResult> specification, CancellationToken cancellationToken = default);
5151

5252
/// <summary>

0 commit comments

Comments
 (0)