|
|
@ -2,6 +2,7 @@ |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
using Microsoft.Extensions.Options; |
|
|
using Microsoft.Extensions.Options; |
|
|
|
|
|
using Nito.AsyncEx; |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
@ -62,6 +63,32 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore |
|
|
return savedEntity; |
|
|
return savedEntity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override async Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var entity in entities) |
|
|
|
|
|
{ |
|
|
|
|
|
CheckAndSetId(entity); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (BulkOperationProvider != null) |
|
|
|
|
|
{ |
|
|
|
|
|
await BulkOperationProvider.InsertManyAsync<TDbContext, TEntity>( |
|
|
|
|
|
this, |
|
|
|
|
|
entities, |
|
|
|
|
|
autoSave, |
|
|
|
|
|
cancellationToken |
|
|
|
|
|
); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
await DbSet.AddRangeAsync(entities); |
|
|
|
|
|
|
|
|
|
|
|
if (autoSave) |
|
|
|
|
|
{ |
|
|
|
|
|
await DbContext.SaveChangesAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public async override Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
public async override Task<TEntity> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
DbContext.Attach(entity); |
|
|
DbContext.Attach(entity); |
|
|
@ -76,6 +103,28 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore |
|
|
return updatedEntity; |
|
|
return updatedEntity; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override async Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
if (BulkOperationProvider != null) |
|
|
|
|
|
{ |
|
|
|
|
|
await BulkOperationProvider.UpdateManyAsync<TDbContext, TEntity>( |
|
|
|
|
|
this, |
|
|
|
|
|
entities, |
|
|
|
|
|
autoSave, |
|
|
|
|
|
cancellationToken |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DbSet.UpdateRange(entities); |
|
|
|
|
|
|
|
|
|
|
|
if (autoSave) |
|
|
|
|
|
{ |
|
|
|
|
|
await DbContext.SaveChangesAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public async override Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
public async override Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
DbSet.Remove(entity); |
|
|
DbSet.Remove(entity); |
|
|
@ -86,6 +135,27 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override async Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
if (BulkOperationProvider != null) |
|
|
|
|
|
{ |
|
|
|
|
|
await BulkOperationProvider.DeleteManyAsync<TDbContext, TEntity>( |
|
|
|
|
|
this, |
|
|
|
|
|
entities, |
|
|
|
|
|
autoSave, |
|
|
|
|
|
cancellationToken); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
DbSet.RemoveRange(entities); |
|
|
|
|
|
|
|
|
|
|
|
if (autoSave) |
|
|
|
|
|
{ |
|
|
|
|
|
await DbContext.SaveChangesAsync(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public async override Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default) |
|
|
public async override Task<List<TEntity>> GetListAsync(bool includeDetails = false, CancellationToken cancellationToken = default) |
|
|
{ |
|
|
{ |
|
|
return includeDetails |
|
|
return includeDetails |
|
|
@ -113,50 +183,6 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
.ToListAsync(GetCancellationToken(cancellationToken)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public override Task InsertManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
if (BulkOperationProvider != null) |
|
|
|
|
|
{ |
|
|
|
|
|
return BulkOperationProvider.InsertManyAsync<TDbContext, TEntity>( |
|
|
|
|
|
this, |
|
|
|
|
|
entities, |
|
|
|
|
|
autoSave, |
|
|
|
|
|
cancellationToken |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return base.InsertManyAsync(entities, autoSave, cancellationToken); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override Task UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
if (BulkOperationProvider != null) |
|
|
|
|
|
{ |
|
|
|
|
|
return BulkOperationProvider.UpdateManyAsync<TDbContext, TEntity>( |
|
|
|
|
|
this, |
|
|
|
|
|
entities, |
|
|
|
|
|
autoSave, |
|
|
|
|
|
cancellationToken |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return base.UpdateManyAsync(entities, autoSave, cancellationToken); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public override Task DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default) |
|
|
|
|
|
{ |
|
|
|
|
|
if (BulkOperationProvider != null) |
|
|
|
|
|
{ |
|
|
|
|
|
return BulkOperationProvider.DeleteManyAsync<TDbContext, TEntity>( |
|
|
|
|
|
this, |
|
|
|
|
|
entities, |
|
|
|
|
|
autoSave, |
|
|
|
|
|
cancellationToken); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return base.DeleteManyAsync(entities, autoSave, cancellationToken); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected override IQueryable<TEntity> GetQueryable() |
|
|
protected override IQueryable<TEntity> GetQueryable() |
|
|
{ |
|
|
{ |
|
|
return DbSet.AsQueryable(); |
|
|
return DbSet.AsQueryable(); |
|
|
|