From 1ab914d936ade6ef5def4b56f0707ab45ef94d78 Mon Sep 17 00:00:00 2001 From: Fati Iseni Date: Fri, 27 Mar 2026 13:42:44 +0100 Subject: [PATCH] Rename ListAsync repo methods to ToListAsync. --- .../RepositoryBase.cs | 6 +++--- src/QuerySpecification/IReadRepositoryBase.cs | 6 +++--- ...{Repository_ListTests.cs => Repository_ToListTests.cs} | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) rename tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/{Repository_ListTests.cs => Repository_ToListTests.cs} (92%) diff --git a/src/QuerySpecification.EntityFrameworkCore/RepositoryBase.cs b/src/QuerySpecification.EntityFrameworkCore/RepositoryBase.cs index ecf08926..336a5018 100644 --- a/src/QuerySpecification.EntityFrameworkCore/RepositoryBase.cs +++ b/src/QuerySpecification.EntityFrameworkCore/RepositoryBase.cs @@ -124,19 +124,19 @@ public virtual async Task FirstAsync(Specification } /// - public virtual async Task> ListAsync(CancellationToken cancellationToken = default) + public virtual async Task> ToListAsync(CancellationToken cancellationToken = default) { return await _dbContext.Set().ToListAsync(cancellationToken); } /// - public virtual async Task> ListAsync(Specification specification, CancellationToken cancellationToken = default) + public virtual async Task> ToListAsync(Specification specification, CancellationToken cancellationToken = default) { return await GenerateQuery(specification).ToListAsync(cancellationToken); } /// - public virtual async Task> ListAsync(Specification specification, CancellationToken cancellationToken = default) + public virtual async Task> ToListAsync(Specification specification, CancellationToken cancellationToken = default) { return await GenerateQuery(specification).ToListAsync(cancellationToken); } diff --git a/src/QuerySpecification/IReadRepositoryBase.cs b/src/QuerySpecification/IReadRepositoryBase.cs index ecab0c4d..3125e179 100644 --- a/src/QuerySpecification/IReadRepositoryBase.cs +++ b/src/QuerySpecification/IReadRepositoryBase.cs @@ -73,7 +73,7 @@ public interface IReadRepositoryBase where T : class /// /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the list of all entities. - Task> ListAsync(CancellationToken cancellationToken = default); + Task> ToListAsync(CancellationToken cancellationToken = default); /// /// Gets a list of entities that match the specification. @@ -81,7 +81,7 @@ public interface IReadRepositoryBase where T : class /// The specification to evaluate. /// The cancellation token. /// A task that represents the asynchronous operation. The task result contains the list of entities that match the specification. - Task> ListAsync(Specification specification, CancellationToken cancellationToken = default); + Task> ToListAsync(Specification specification, CancellationToken cancellationToken = default); /// /// Gets a list of entities that match the specification and projects them to a result. @@ -90,7 +90,7 @@ public interface IReadRepositoryBase where T : class /// The specification to evaluate. /// The cancellation token. /// 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. - Task> ListAsync(Specification specification, CancellationToken cancellationToken = default); + Task> ToListAsync(Specification specification, CancellationToken cancellationToken = default); /// /// Gets the count of all entities. diff --git a/tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/Repository_ListTests.cs b/tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/Repository_ToListTests.cs similarity index 92% rename from tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/Repository_ListTests.cs rename to tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/Repository_ToListTests.cs index 19f80751..bd836887 100644 --- a/tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/Repository_ListTests.cs +++ b/tests/QuerySpecification.EntityFrameworkCore.Tests/Repositories/Repository_ToListTests.cs @@ -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); @@ -18,7 +18,7 @@ public async Task ListAsync_ReturnsAllItems() var repo = new Repository(DbContext); - var result = await repo.ListAsync(); + var result = await repo.ToListAsync(); result.Should().HaveSameCount(expected); result.Should().BeEquivalentTo(expected); @@ -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); @@ -77,7 +77,7 @@ await SeedRangeAsync( .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);