64 lines
3.0 KiB
C#
64 lines
3.0 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq.Expressions;
|
||
using System.Text;
|
||
using System.Threading;
|
||
using System.Threading.Tasks;
|
||
using IRaCIS.Core.Domain.Models;
|
||
using Microsoft.EntityFrameworkCore.ChangeTracking;
|
||
|
||
namespace IRaCIS.Core.Infra.EFCore
|
||
{
|
||
public interface ICommandRepository<TEntity>: ICommandRepository<TEntity, Guid> where TEntity : Entity
|
||
{
|
||
Task<TEntity> InsertOrUpdateAsync<TFrom>(TFrom from, bool autoSave = false, params EntityVerifyExp<TEntity>[] verify);
|
||
|
||
Task<TEntity> InsertFromDTOAsync<TFrom>(TFrom from, bool autoSave = false, params EntityVerifyExp<TEntity>[] verify);
|
||
|
||
Task<TEntity> UpdateFromDTOAsync<TFrom>(TFrom from, bool autoSave = false, bool ignoreDtoNullProperty = true, params EntityVerifyExp<TEntity>[] verify);
|
||
|
||
|
||
Task<TEntity> UpdatePartialFields(TEntity entity, string[] propertyNames, bool autoSave = false, bool ignoreEntityNullProperty = true, params EntityVerifyExp<TEntity>[] verify);
|
||
|
||
Task<TEntity> UpdatePartialFields(Guid id, Expression<Func<TEntity, TEntity>> updateFactory, bool autoSave = false, params EntityVerifyExp<TEntity>[] verify);
|
||
|
||
|
||
Task<bool> BatchDeleteAsync(Expression<Func<TEntity, bool>> deleteFilter);
|
||
Task<bool> BatchUpdateAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory);
|
||
|
||
}
|
||
|
||
public interface ICommandRepository<TEntity, TKey> where TEntity : class
|
||
{
|
||
EntityEntry<TEntity> Attach(TEntity entity);
|
||
|
||
EntityEntry Entry(TEntity t);
|
||
|
||
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> exp = null, bool ignoreQueryFilters = false);
|
||
|
||
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> exp,bool ignoreQueryFilters=false);
|
||
|
||
Task<TResult> MaxAsync<TResult>(Expression<Func<TEntity, TResult>> selector);
|
||
|
||
Task<int> CountAsync(Expression<Func<TEntity, bool>> whereLambda = null, bool ignoreQueryFilters = false);
|
||
|
||
ValueTask<TEntity> AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
|
||
|
||
Task<IEnumerable<TEntity>> AddRangeAsync(IEnumerable<TEntity> entities);
|
||
|
||
Task<bool> AddRangeAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
|
||
// 不建议使用,使用跟踪,然后save 部分字段更新,此种方式是更新所有字段
|
||
Task<bool> UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
|
||
Task<bool> SaveChangesAsync(CancellationToken cancellationToken = default);
|
||
Task<bool> UpdateManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
|
||
Task<bool> DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default);
|
||
Task<bool> DeleteManyAsync(IEnumerable<TEntity> entities, bool autoSave = false, CancellationToken cancellationToken = default);
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
}
|