CommonDAL.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. using Common.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Linq.Expressions;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using UC.DAL.IDAL;
  9. using UC.Models;
  10. namespace UC.DAL
  11. {
  12. public class CommonDAL : BaseDAL, ICommonDAL
  13. {
  14. #region 查询
  15. /// <summary>
  16. /// 分页查询-Lambda
  17. /// </summary>
  18. /// <typeparam name="T"></typeparam>
  19. /// <param name="condition"></param>
  20. /// <param name="pagination"></param>
  21. /// <returns></returns>
  22. public PaginationDTO<IEnumerable<T>> FindPageList<T>(Expression<Func<T, bool>> condition, PaginationQuery pagination) where T : class, new()
  23. {
  24. return db.FindPageList<T>(condition, pagination);
  25. }
  26. /// <summary>
  27. /// 集合查询(Lambda)
  28. /// </summary>
  29. /// <typeparam name="T"></typeparam>
  30. /// <param name="condition"></param>
  31. /// <returns></returns>
  32. public IEnumerable<T> FindList<T>(Expression<Func<T, bool>> condition) where T : class, new()
  33. {
  34. return db.FindList<T>(condition);
  35. }
  36. /// <summary>
  37. /// 集合查询(Lambda)
  38. /// </summary>
  39. /// <typeparam name="T"></typeparam>
  40. /// <param name="condition"></param>
  41. /// <returns></returns>
  42. public T FindEntity<T>(Expression<Func<T, bool>> condition) where T : class, new()
  43. {
  44. return db.FindEntity<T>(condition);
  45. }
  46. /// <summary>
  47. /// 数据条数
  48. /// </summary>
  49. /// <typeparam name="T"></typeparam>
  50. /// <param name="condition"></param>
  51. /// <returns></returns>
  52. public int Count<T>(Expression<Func<T, bool>> condition) where T : class, new()
  53. {
  54. return db.Count<T>(condition);
  55. }
  56. #endregion
  57. #region 编辑
  58. /// <summary>
  59. /// 实体新增
  60. /// </summary>
  61. /// <typeparam name="T"></typeparam>
  62. /// <param name="model"></param>
  63. /// <returns></returns>
  64. public int Insert<T>(T model) where T : class, new()
  65. {
  66. return db.Insert<T>(model);
  67. }
  68. /// <summary>
  69. /// 批量实体新增
  70. /// </summary>
  71. /// <typeparam name="T"></typeparam>
  72. /// <param name="list"></param>
  73. /// <returns></returns>
  74. public int Insert<T>(List<T> list) where T : class, new()
  75. {
  76. return db.Insert<T>(list);
  77. }
  78. /// <summary>
  79. /// 修改lammbda
  80. /// </summary>
  81. /// <typeparam name="T"></typeparam>
  82. /// <param name="t"></param>
  83. /// <returns></returns>
  84. public int Update<T>(T model) where T : class, new()
  85. {
  86. return db.Update<T>(model);
  87. }
  88. #endregion
  89. #region 删除
  90. /// <summary>
  91. /// 泛型删除
  92. /// </summary>
  93. /// <typeparam name="T"></typeparam>
  94. /// <param name="t"></param>
  95. /// <returns></returns>
  96. public int Delete<T>(T model) where T : class, new()
  97. {
  98. return db.Delete<T>(model);
  99. }
  100. /// <summary>
  101. /// 泛型删除
  102. /// </summary>
  103. /// <typeparam name="T"></typeparam>
  104. /// <param name="t"></param>
  105. /// <returns></returns>
  106. public int Delete<T>(int id) where T : class, new()
  107. {
  108. return db.Delete<T>(id);
  109. }
  110. #endregion
  111. }
  112. }