IBaseRepository.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using SqlSugar;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq.Expressions;
  6. using System.Threading.Tasks;
  7. using ZR.Model;
  8. namespace ZR.Repository
  9. {
  10. public interface IBaseRepository<T> : ISimpleClient<T> where T : class, new()
  11. {
  12. #region add
  13. int Add(T t, bool ignoreNull = true);
  14. int Insert(List<T> t);
  15. int Insert(T parm, Expression<Func<T, object>> iClumns = null, bool ignoreNull = true);
  16. IInsertable<T> Insertable(T t);
  17. #endregion add
  18. #region update
  19. int Update(T entity, bool ignoreNullColumns = false, object data = null);
  20. /// <summary>
  21. /// 只更新表达式的值
  22. /// </summary>
  23. /// <param name="entity"></param>
  24. /// <param name="expression"></param>
  25. /// <returns></returns>
  26. int Update(T entity, Expression<Func<T, object>> expression, bool ignoreAllNull = false);
  27. int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
  28. int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
  29. Task<int> UpdateAsync(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
  30. #endregion update
  31. DbResult<bool> UseTran(Action action);
  32. DbResult<bool> UseTran(ISqlSugarClient client, Action action);
  33. bool UseTran2(Action action);
  34. #region delete
  35. IDeleteable<T> Deleteable();
  36. int Delete(object id, string title = "");
  37. int DeleteTable();
  38. bool Truncate();
  39. #endregion delete
  40. #region query
  41. /// <summary>
  42. /// 根据条件查询分页数据
  43. /// </summary>
  44. /// <param name="where"></param>
  45. /// <param name="parm"></param>
  46. /// <returns></returns>
  47. PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm);
  48. PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, OrderByType orderEnum = OrderByType.Asc);
  49. PagedInfo<T> GetPages(Expression<Func<T, bool>> where, PagerInfo parm, Expression<Func<T, object>> order, string orderByType);
  50. bool Any(Expression<Func<T, bool>> expression);
  51. ISugarQueryable<T> Queryable();
  52. List<T> GetAll(bool useCache = false, int cacheSecond = 3600);
  53. List<T> SqlQueryToList(string sql, object obj = null);
  54. T GetId(object pkValue);
  55. #endregion query
  56. #region Procedure
  57. DataTable UseStoredProcedureToDataTable(string procedureName, List<SugarParameter> parameters);
  58. (DataTable, List<SugarParameter>) UseStoredProcedureToTuple(string procedureName, List<SugarParameter> parameters);
  59. #endregion Procedure
  60. }
  61. }