Compare commits
3 Commits
5567f6731b
...
0cf6d2690a
| Author | SHA1 | Date | |
|---|---|---|---|
| 0cf6d2690a | |||
| afbbac7b81 | |||
| d16a4b6bb4 |
@ -12,9 +12,9 @@
|
||||
<PackageIcon>core_icon.png</PackageIcon>
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/WebCoreModules.git</RepositoryUrl>
|
||||
<PackageTags>digital data core application clean architecture abstraction</PackageTags>
|
||||
<Version>1.4.0</Version>
|
||||
<AssemblyVersion>1.4.0</AssemblyVersion>
|
||||
<FileVersion>1.4.0</FileVersion>
|
||||
<Version>1.5.0</Version>
|
||||
<AssemblyVersion>1.5.0</AssemblyVersion>
|
||||
<FileVersion>1.5.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using DigitalData.Core.Abstractions.Interfaces;
|
||||
using System.Linq.Expressions;
|
||||
using System.Linq.Expressions;
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -71,6 +70,16 @@ public interface IRepository<TEntity>
|
||||
public
|
||||
#endif
|
||||
Task UpdateAsync<TDto>(TDto dto, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
|
||||
|
||||
#if NET
|
||||
public
|
||||
#endif
|
||||
Task UpdateAsync(Action<TEntity> modification, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default);
|
||||
|
||||
#if NET
|
||||
public
|
||||
#endif
|
||||
Task UpdateAsync(Action<TEntity> modification, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default);
|
||||
#endregion Update
|
||||
|
||||
#region Delete
|
||||
|
||||
@ -87,22 +87,25 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
|
||||
#region Update
|
||||
public virtual Task UpdateAsync<TDto>(TDto dto, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default) => UpdateAsync(dto, q => q.Where(expression), cancel);
|
||||
|
||||
public virtual async Task UpdateAsync<TDto>(TDto dto, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default)
|
||||
public virtual Task UpdateAsync<TDto>(TDto dto, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default)
|
||||
=> UpdateAsync(entity => Mapper
|
||||
#if NET
|
||||
!
|
||||
#endif
|
||||
.Map(dto, entity), query, cancel);
|
||||
|
||||
public virtual async Task UpdateAsync(Action<TEntity> modification, Func<IQueryable<TEntity>, IQueryable<TEntity>> query, CancellationToken cancel = default)
|
||||
{
|
||||
var entities = await query(Entities).ToListAsync(cancel);
|
||||
|
||||
for (int i = entities.Count - 1; i >= 0; i--)
|
||||
{
|
||||
Mapper
|
||||
#if NET
|
||||
!
|
||||
#endif
|
||||
.Map(dto, entities[i]);
|
||||
Entities.Update(entities[i]);
|
||||
}
|
||||
modification.Invoke(entities[i]);
|
||||
|
||||
await Context.SaveChangesAsync(cancel);
|
||||
}
|
||||
|
||||
public virtual Task UpdateAsync(Action<TEntity> modification, Expression<Func<TEntity, bool>> expression, CancellationToken cancel = default)
|
||||
=> UpdateAsync(modification, q => q.Where(expression), cancel);
|
||||
#endregion Update
|
||||
|
||||
#region Delete
|
||||
|
||||
@ -13,9 +13,9 @@
|
||||
<RepositoryUrl>http://git.dd:3000/AppStd/WebCoreModules.git</RepositoryUrl>
|
||||
<RepositoryType>digital data core abstractions clean architecture</RepositoryType>
|
||||
<PackageTags>digital data core infrastructure clean architecture</PackageTags>
|
||||
<Version>2.4.5</Version>
|
||||
<AssemblyVersion>2.4.5</AssemblyVersion>
|
||||
<FileVersion>2.4.5</FileVersion>
|
||||
<Version>2.5.0</Version>
|
||||
<AssemblyVersion>2.5.0</AssemblyVersion>
|
||||
<FileVersion>2.5.0</FileVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user