CostCalculationItem/IRaCIS.Core.Domain/IRepository.cs

49 lines
1.7 KiB
C#

using Microsoft.EntityFrameworkCore.ChangeTracking;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace IRaCIS.Core.Domain
{
/// <summary>
/// 仓储接口
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IRepository<T> where T : class
{
IQueryable<T> GetAll();
T Add(T t);
IEnumerable<T> AddRange(IEnumerable<T> t);
void Delete(T t);
bool Delete(Expression<Func<T, bool>> exp);
void Update(T t);
Task AddOrUpdateAsync(T t);
bool Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> entity);
bool IsExist(Expression<Func<T, bool>> exp);
int GetCount(Expression<Func<T, bool>> exp=null);
T FindSingleOrDefault(Expression<Func<T, bool>> exp = null);
IQueryable<T> Find(Expression<Func<T, bool>> exp = null);
IQueryable<T> Find<type>(int pageSize, int pageIndex, bool isAsc, Expression<Func<T, type>> orderByLambda, Expression<Func<T, bool>> whereLambda=null);
IQueryable<T> Find(int pageSize, int pageIndex, bool isAsc, string propName,
Expression<Func<T, bool>> whereLambda);
bool SaveChanges();
ValueTask<EntityEntry<T>> AddAsync(T entity);
Task<int> DeleteAsync(Expression<Func<T, bool>> whereLambda);
Task<int> UpdateAsync(Expression<Func<T, bool>> whereLambda, Expression<Func<T, T>> entity);
Task<bool> IsExistAsync(Expression<Func<T, bool>> whereLambda);
Task<T> GetFirstOrDefaultAsync(Expression<Func<T, bool>> whereLambda);
Task<int> GetCountAsync(Expression<Func<T, bool>> whereLambda = null);
Task<int> SaveChangesAsync();
}
}