53 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			C#
		
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			2.4 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);
 | ||
|         
 | ||
|     }
 | ||
| 
 | ||
|     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);   
 | ||
| 
 | ||
|         Task<bool> DeleteFromQueryAsync(Expression<Func<TEntity, bool>> deleteFilter) ;
 | ||
|         Task<bool> UpdateFromQueryAsync(Expression<Func<TEntity, bool>> where, Expression<Func<TEntity, TEntity>> updateFactory);
 | ||
| 
 | ||
|     }
 | ||
| 
 | ||
| 
 | ||
| 
 | ||
| }
 |