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: ICommandRepository where TEntity : Entity { Task InsertOrUpdateAsync(TFrom from, bool autoSave = false, params EntityVerifyExp[] verify); Task InsertFromDTOAsync(TFrom from, bool autoSave = false, params EntityVerifyExp[] verify); Task UpdateFromDTOAsync(TFrom from, bool autoSave = false, bool ignoreDtoNullProperty = true, params EntityVerifyExp[] verify); Task UpdatePartialFields(TEntity entity, string[] propertyNames, bool autoSave = false, bool ignoreEntityNullProperty = true, params EntityVerifyExp[] verify); Task UpdatePartialFieldsNow(Guid id, Expression> updateFactory, params EntityVerifyExp[] verify); Task UpdatePartialFields(Guid id, Expression> updateFactory, bool autoSave = false, params EntityVerifyExp[] verify); Task BatchDeleteAsync(Expression> deleteFilter); Task BatchUpdateAsync(Expression> where, Expression> updateFactory); } public interface ICommandRepository where TEntity : class { EntityEntry Attach(TEntity entity); EntityEntry Entry(TEntity t); Task FirstOrDefaultAsync(Expression> exp = null, bool ignoreQueryFilters = false); Task AnyAsync(Expression> exp,bool ignoreQueryFilters=false); Task MaxAsync(Expression> selector); Task CountAsync(Expression> whereLambda = null, bool ignoreQueryFilters = false); ValueTask AddAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); Task> AddRangeAsync(IEnumerable entities); Task AddRangeAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default); // 不建议使用,使用跟踪,然后save 部分字段更新,此种方式是更新所有字段 Task UpdateAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); Task SaveChangesAsync(CancellationToken cancellationToken = default); Task DeleteAsync(TEntity entity, bool autoSave = false, CancellationToken cancellationToken = default); //Task DeleteManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default); //Task UpdateManyAsync(IEnumerable entities, bool autoSave = false, CancellationToken cancellationToken = default); } }