IBaseRepository.cs 2.6 KB

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