MapperKeyScalarDateExt.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using BO.AppServer.Data;
  4. using Quadarax.Foundation.Core.Data.Interface.Entity;
  5. namespace BO.AppServer.Business.Mapper
  6. {
  7. public static class MapperKeyScalarDateExt
  8. {
  9. public static TDto Map<TDao, TDto>(this TDao dao)
  10. where TDao : class, IDao<KeyScalarDate>, new()
  11. where TDto : class, IDto, new()
  12. {
  13. if (dao == null) return null;
  14. return MapperKeyScalarDate.Instance.Map<TDao, TDto>(dao);
  15. }
  16. public static TDao MapDto<TDto, TDao>(this TDto dto)
  17. where TDao : class, IDao<KeyScalarDate>, new()
  18. where TDto : class, IDto, new()
  19. {
  20. if (dto == null) return null;
  21. return MapperKeyScalarDate.Instance.Map<TDto, TDao>(dto);
  22. }
  23. public static void CopyToDto<TDto, TDao>(this TDto @from, TDao to)
  24. where TDao : class, IDao<KeyScalarDate>, new()
  25. where TDto : class, IDto, new()
  26. {
  27. if (@from == null) return;
  28. if (to == null) return;
  29. MapperKeyScalarDate.Instance.Update(@from,to);
  30. }
  31. public static void CopyToDto<TDto, TDao>(this TDao @from, TDto to)
  32. where TDao : class, IDao<KeyScalarDate>, new()
  33. where TDto : class, IDto, new()
  34. {
  35. if (to == null) return;
  36. if (@from == null) return;
  37. MapperKeyScalarDate.Instance.Update(@from,to);
  38. }
  39. public static List<TDto> MapList<TDao, TDto>(this IQueryable<TDao> dao)
  40. where TDao : class, IDao<KeyScalarDate>, new()
  41. where TDto : class, IDto, new()
  42. {
  43. if (dao == null) return new List<TDto>();
  44. return MapperKeyScalarDate.Instance.MapList<TDao, TDto>(dao);
  45. }
  46. public static List<TDto> MapList<TDao, TDto>(this IEnumerable<TDao> dao)
  47. where TDao : class, IDao<KeyScalarDate>, new()
  48. where TDto : class, IDto, new()
  49. {
  50. if (dao == null) return new List<TDto>();
  51. return MapperKeyScalarDate.Instance.MapList<TDao, TDto>(dao);
  52. }
  53. public static List<TDto> MapList<TDao, TDto>(this IList<TDao> dao)
  54. where TDao : class, IDao<KeyScalarDate>, new()
  55. where TDto : class, IDto, new()
  56. {
  57. if (dao == null) return new List<TDto>();
  58. return MapperKeyScalarDate.Instance.MapList<TDao, TDto>(dao);
  59. }
  60. public static IQueryable<TDao> MapListDto<TDto,TDao>(this IEnumerable<TDto> dto)
  61. where TDao : class, IDao<KeyScalarDate>, new()
  62. where TDto : class, IDto, new()
  63. {
  64. if (dto == null) return new List<TDao>().AsQueryable();
  65. return MapperKeyScalarDate.Instance.MapList<TDto, TDao>(dto.AsQueryable()).AsQueryable();
  66. }
  67. }
  68. }