using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace Haoliang.Data.Repositories { public interface IRepository where T : class { Task GetByIdAsync(int id); Task> GetAllAsync(); Task> FindAsync(System.Linq.Expressions.Expression> predicate); Task SingleOrDefaultAsync(System.Linq.Expressions.Expression> predicate); Task AddAsync(T entity); Task AddRangeAsync(IEnumerable entities); void Update(T entity); void Remove(T entity); void RemoveRange(IEnumerable entities); Task CountAsync(System.Linq.Expressions.Expression> predicate = null); Task ExistsAsync(System.Linq.Expressions.Expression> predicate); Task SaveAsync(); } public interface IReadRepository where T : class { Task GetByIdAsync(int id); Task> GetAllAsync(); Task> FindAsync(System.Linq.Expressions.Expression> predicate); Task SingleOrDefaultAsync(System.Linq.Expressions.Expression> predicate); Task CountAsync(System.Linq.Expressions.Expression> predicate = null); Task ExistsAsync(System.Linq.Expressions.Expression> predicate); } public interface IWriteRepository where T : class { Task AddAsync(T entity); Task AddRangeAsync(IEnumerable entities); void Update(T entity); void Remove(T entity); void RemoveRange(IEnumerable entities); Task SaveAsync(); } }