Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/QuerySpecification.EntityFrameworkCore/RepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ public virtual async Task<TResult> FirstAsync<TResult>(Specification<T, TResult>
}

/// <inheritdoc/>
public virtual async Task<List<T>> ListAsync(CancellationToken cancellationToken = default)
public virtual async Task<List<T>> ToListAsync(CancellationToken cancellationToken = default)
{
return await _dbContext.Set<T>().ToListAsync(cancellationToken);
}

/// <inheritdoc/>
public virtual async Task<List<T>> ListAsync(Specification<T> specification, CancellationToken cancellationToken = default)
public virtual async Task<List<T>> ToListAsync(Specification<T> specification, CancellationToken cancellationToken = default)
{
return await GenerateQuery(specification).ToListAsync(cancellationToken);
}

/// <inheritdoc/>
public virtual async Task<List<TResult>> ListAsync<TResult>(Specification<T, TResult> specification, CancellationToken cancellationToken = default)
public virtual async Task<List<TResult>> ToListAsync<TResult>(Specification<T, TResult> specification, CancellationToken cancellationToken = default)
{
return await GenerateQuery(specification).ToListAsync(cancellationToken);
}
Expand Down
6 changes: 3 additions & 3 deletions src/QuerySpecification/IReadRepositoryBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@ public interface IReadRepositoryBase<T> where T : class
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the list of all entities.</returns>
Task<List<T>> ListAsync(CancellationToken cancellationToken = default);
Task<List<T>> ToListAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Gets a list of entities that match the specification.
/// </summary>
/// <param name="specification">The specification to evaluate.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the list of entities that match the specification.</returns>
Task<List<T>> ListAsync(Specification<T> specification, CancellationToken cancellationToken = default);
Task<List<T>> ToListAsync(Specification<T> specification, CancellationToken cancellationToken = default);

/// <summary>
/// Gets a list of entities that match the specification and projects them to a result.
Expand All @@ -90,7 +90,7 @@ public interface IReadRepositoryBase<T> where T : class
/// <param name="specification">The specification to evaluate.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>A task that represents the asynchronous operation. The task result contains the list of entities that match the specification and are projected to a result.</returns>
Task<List<TResult>> ListAsync<TResult>(Specification<T, TResult> specification, CancellationToken cancellationToken = default);
Task<List<TResult>> ToListAsync<TResult>(Specification<T, TResult> specification, CancellationToken cancellationToken = default);

/// <summary>
/// Gets the count of all entities.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Tests.Repositories;

[Collection("SharedCollection")]
public class Repository_ListTests(TestFactory factory) : IntegrationTest(factory)
public class Repository_ToListTests(TestFactory factory) : IntegrationTest(factory)
{
public record CountryDto(string? Name);

Expand All @@ -18,7 +18,7 @@ public async Task ListAsync_ReturnsAllItems()

var repo = new Repository<Country>(DbContext);

var result = await repo.ListAsync();
var result = await repo.ToListAsync();

result.Should().HaveSameCount(expected);
result.Should().BeEquivalentTo(expected);
Expand Down Expand Up @@ -46,7 +46,7 @@ await SeedRangeAsync(
spec.Query
.Where(x => x.Name == "b");

var result = await repo.ListAsync(spec);
var result = await repo.ToListAsync(spec);

result.Should().HaveSameCount(expected);
result.Should().BeEquivalentTo(expected);
Expand Down Expand Up @@ -77,7 +77,7 @@ await SeedRangeAsync<Country>(
.Where(x => x.Name == "b")
.Select(x => new CountryDto(x.Name));

var result = await repo.ListAsync(spec);
var result = await repo.ToListAsync(spec);

result.Should().HaveSameCount(expected);
result.Should().BeEquivalentTo(expected);
Expand Down
Loading