Skip to content

Commit f5777b9

Browse files
author
Adrian Hall
committed
(#173) WIP: Cosmos changes to counteract breaking changes in EF 9.x.
1 parent 6524bc6 commit f5777b9

File tree

6 files changed

+429
-27
lines changed

6 files changed

+429
-27
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace CommunityToolkit.Datasync.Server.EntityFrameworkCore;
1010
/// <summary>
1111
/// The base class for all the Entity Framework Core based table data classes.
1212
/// </summary>
13-
[Index(nameof(UpdatedAt), nameof(Deleted))]
1413
public abstract class BaseEntityTableData : ITableData
1514
{
1615
/// <inheritdoc />

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using Microsoft.EntityFrameworkCore;
56
using System.ComponentModel.DataAnnotations;
67
using System.ComponentModel.DataAnnotations.Schema;
78

@@ -11,6 +12,7 @@ namespace CommunityToolkit.Datasync.Server.EntityFrameworkCore;
1112
/// A version of the <see cref="BaseEntityTableData"/> that is compatible with
1213
/// most of the Entity Framework Core drivers.
1314
/// </summary>
15+
[Index(nameof(UpdatedAt), nameof(Deleted))]
1416
public class EntityTableData : BaseEntityTableData
1517
{
1618
/// <inheritdoc />

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public virtual async ValueTask CreateAsync(TEntity entity, CancellationToken can
138138
await WrapExceptionAsync(entity.Id, async () =>
139139
{
140140
// We do not use Any() here because it is not supported by all providers (e.g. Cosmos)
141-
if (DataSet.Count(x => x.Id == entity.Id) > 0)
141+
if ((await DataSet.CountAsync(x => x.Id == entity.Id, cancellationToken)) > 0)
142142
{
143143
throw new HttpException((int)HttpStatusCode.Conflict) { Payload = await GetEntityAsync(entity.Id, cancellationToken).ConfigureAwait(false) };
144144
}

0 commit comments

Comments
 (0)