Skip to content
This repository was archived by the owner on Aug 10, 2024. It is now read-only.
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ private async Task<int> UpdateEntriesAsync<TEntity>(

/// <inheritdoc />
public override Func<QueryContext, IAsyncEnumerable<TResult>> CompileAsyncQuery<TResult>(QueryModel queryModel)
=> queryContext => CompileQuery<TResult>(queryModel)(queryContext).ToAsyncEnumerable();
{
var syncQueryExecutor = CompileQuery<TResult>(queryModel);
return queryContext => syncQueryExecutor(queryContext).ToAsyncEnumerable();
}

private IUpdateEntry GetRootDocument(InternalEntityEntry entry)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,38 @@ await zooDbContext.Animals
});
}

[Fact]
public async Task Can_execute_same_async_query_from_different_dbContext_instances()
{
await ExecuteUnitOfWorkAsync(async zooDbContext =>
{
zooDbContext.Animals.AddRange(_zooEntities.Animals);
Assert.Equal(
_zooEntities.Entities.Count,
await zooDbContext.SaveChangesAsync(acceptAllChangesOnSuccess: true));
});

Func<ZooDbContext, Task<List<Animal>>> query = (zooDbContext) =>
zooDbContext.Animals
.OrderBy(animal => animal.Name)
.ThenBy(animal => animal.Height)
.ToListAsync();

await ExecuteUnitOfWorkAsync(async zooDbContext =>
{
Assert.Equal(_zooEntities.Animals,
await query.Invoke(zooDbContext),
new AnimalEqualityComparer());
});

await ExecuteUnitOfWorkAsync(async zooDbContext =>
{
Assert.Equal(_zooEntities.Animals,
await query.Invoke(zooDbContext),
new AnimalEqualityComparer());
});
}

[Fact]
public async Task Can_query_first_or_default_async()
{
Expand Down