Skip to content

Commit b15e7d3

Browse files
authored
Merge pull request #67 from cnblogs/fix-ambious-calling
fix: ambiguous calling of GetAsync()
2 parents 2056760 + 2951dc8 commit b15e7d3

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Cnblogs.Architecture.Ddd.Domain.Abstractions/INavigationRepository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ public interface INavigationRepository<TEntity, TKey> : IRepository<TEntity, TKe
2525
/// <param name="key">The key of entity.</param>
2626
/// <param name="includes">Include strings.</param>
2727
/// <returns>The entity with key equals to <paramref name="key"/>.</returns>
28-
Task<TEntity?> GetAsync(TKey key, params string[] includes);
28+
Task<TEntity?> GetAsync(TKey key, IEnumerable<string> includes);
2929
}

src/Cnblogs.Architecture.Ddd.Infrastructure.EntityFramework/BaseRepository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public async Task<TEnumerable> AddRangeAsync<TEnumerable>(TEnumerable entities)
7878
}
7979

8080
/// <inheritdoc />
81-
public async Task<TEntity?> GetAsync(TKey key, params string[] includes)
81+
public async Task<TEntity?> GetAsync(TKey key, IEnumerable<string> includes)
8282
{
8383
return await Context.Set<TEntity>().AggregateIncludes(includes).FirstOrDefaultAsync(e => e.Id.Equals(key));
8484
}

test/Cnblogs.Architecture.UnitTests/Infrastructure/EntityFramework/BaseRepositoryTests.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public async Task GetEntityAsync_StringBasedInclude_NotNullAsync()
5555
var repository = new TestRepository(Mock.Of<IMediator>(), db);
5656

5757
// Act
58-
var got = await repository.GetAsync(entity.Id, nameof(entity.Posts));
58+
var got = await repository.GetAsync(entity.Id, new List<string>() { nameof(entity.Posts) });
5959

6060
// Assert
6161
got.Should().NotBeNull();
@@ -82,7 +82,7 @@ public async Task GetEntityAsync_ThenInclude_NotNullAsync()
8282
var repository = new TestRepository(Mock.Of<IMediator>(), db);
8383

8484
// Act
85-
var got = await repository.GetAsync(entity.Id, "Posts.Tags");
85+
var got = await repository.GetAsync(entity.Id, new List<string>() { "Posts.Tags" });
8686

8787
// Assert
8888
got.Should().NotBeNull();

0 commit comments

Comments
 (0)