Skip to content

Commit

Permalink
Added unsafe mode for shadow primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas committed Nov 10, 2023
1 parent f022d28 commit 0e91d95
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/BUTR.Site.NexusMods.Server/Extensions/DbSetExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ public static async Task SynchronizeOnSaveAsync<TEntity>(this DbSet<TEntity> dbS
}


public static async Task UpsertAsync<TEntity>(this DbSet<TEntity> dbSet, IEnumerable<TEntity> entities) where TEntity : class, IEntity
public static async Task UpsertAsync<TEntity>(this DbSet<TEntity> dbSet, IEnumerable<TEntity> entities, bool @unsafe = false) where TEntity : class, IEntity
{
await dbSet.BulkMergeAsync(entities);
await dbSet.BulkMergeAsync(entities, o => o.UnsafeMode = @unsafe);
}
public static async Task UpsertAsync<TEntity>(this DbSet<TEntity> dbSet, IAsyncEnumerable<TEntity> entities) where TEntity : class, IEntity
public static async Task UpsertAsync<TEntity>(this DbSet<TEntity> dbSet, IAsyncEnumerable<TEntity> entities, bool @unsafe = false) where TEntity : class, IEntity
{
await dbSet.BulkMergeAsync(await entities.ToArrayAsync());
await dbSet.BulkMergeAsync(await entities.ToArrayAsync(), o => o.UnsafeMode = @unsafe);
}
public static async Task UpsertAsync<TEntity>(this DbSet<TEntity> dbSet, params TEntity[] entities) where TEntity : class, IEntity
public static async Task UpsertAsync<TEntity>(this DbSet<TEntity> dbSet, bool @unsafe = false, params TEntity[] entities) where TEntity : class, IEntity
{
await dbSet.BulkMergeAsync(entities);
await dbSet.BulkMergeAsync(entities, o => o.UnsafeMode = @unsafe);
}

public static async Task SynchronizeAsync<TEntity>(this DbSet<TEntity> dbSet, IEnumerable<TEntity> entities) where TEntity : class, IEntity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static async Task HandleTenantAsync(TenantId tenant, IServiceProvider se
TenantId = tenant,
Type = key,
Value = x,
}));
}), true);
}

/*
Expand Down

0 comments on commit 0e91d95

Please sign in to comment.