Skip to content

Commit 6cc46bd

Browse files
author
Adrian Hall
committed
(#199) Async support in the EF Core repository pattern.
1 parent 72a0f1e commit 6cc46bd

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/CommunityToolkit.Datasync.Server.EntityFrameworkCore/EntityTableRepository.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,17 @@ await WrapExceptionAsync(entity.Id, async () =>
209209
_ = await Context.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
210210
}, cancellationToken).ConfigureAwait(false);
211211
}
212+
213+
/// <inheritdoc />
214+
public virtual async ValueTask<int> CountAsync(IQueryable<TEntity> query, CancellationToken cancellationToken = default)
215+
{
216+
return await query.CountAsync(cancellationToken);
217+
}
218+
219+
/// <inheritdoc />
220+
public virtual async ValueTask<IList<TEntity>> ToListAsync(IQueryable<TEntity> query, CancellationToken cancellationToken = default)
221+
{
222+
return await query.ToListAsync(cancellationToken);
223+
}
212224
#endregion
213225
}

tests/CommunityToolkit.Datasync.TestCommon/Databases/CosmosDb/CosmosDbContext.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ internal void InitializeDatabase(bool clearEntities)
3838
}
3939
}
4040

41-
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
42-
{
43-
optionsBuilder.ConfigureWarnings(w => w.Ignore(CosmosEventId.SyncNotSupported));
44-
}
41+
// (Issue #199) - remove the sync over async capabilities introduced in .NET 9
42+
//protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
43+
//{
44+
// optionsBuilder.ConfigureWarnings(w => w.Ignore(CosmosEventId.SyncNotSupported));
45+
//}
4546

4647
protected override void OnModelCreating(ModelBuilder modelBuilder)
4748
{

0 commit comments

Comments
 (0)