IRepository.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ServiceModel;
  4. using CB.Entity;
  5. namespace CB.Interface
  6. {
  7. /// <summary>
  8. /// 基础数据操作接口
  9. /// </summary>
  10. /// <typeparam name="TEntity"></typeparam>
  11. public interface IRepository<TEntity> where TEntity : BaseEntity, new()
  12. {
  13. /// <summary>
  14. /// 数据新增操作
  15. /// </summary>
  16. /// <typeparam name="TEntity"></typeparam>
  17. /// <param name="entity"></param>
  18. [OperationContract]
  19. bool Save(TEntity entity);
  20. /// <summary>
  21. /// 数据更新操作
  22. /// </summary>
  23. /// <typeparam name="TEntity"></typeparam>
  24. /// <param name="entity"></param>
  25. [OperationContract]
  26. bool Update(TEntity entity);
  27. /// <summary>
  28. /// 数据删除操作
  29. /// </summary>
  30. /// <typeparam name="TEntity"></typeparam>
  31. /// <param name="entity"></param>
  32. bool Delete(int Id);
  33. /// <summary>
  34. /// 数据获取
  35. /// </summary>
  36. /// <typeparam name="TEntity"></typeparam>
  37. /// <typeparam name="TKey"></typeparam>
  38. /// <param name="key"></param>
  39. /// <returns></returns>
  40. TEntity Get<TKey>(TKey key);
  41. /// <summary>
  42. /// 数据列表
  43. /// </summary>
  44. /// <typeparam name="TEntity"></typeparam>
  45. /// <returns></returns>
  46. IList<TEntity> ToList();
  47. /// <summary>
  48. /// 数据查询
  49. /// </summary>
  50. /// <typeparam name="TEntity"></typeparam>
  51. /// <param name="entity"></param>
  52. /// <returns></returns>
  53. IList<TEntity> ToList(TEntity entity);
  54. /// <summary>
  55. /// 翻页查询数据列表
  56. /// </summary>
  57. /// <param name="entity"></param>
  58. /// <param name="pageSize"></param>
  59. /// <param name="pageIndex"></param>
  60. /// <param name="recordCount"></param>
  61. /// <returns></returns>
  62. IList<TEntity> ToPaging(TEntity entity, int pageSize, int pageIndex, out int recordCount);
  63. }
  64. }