| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using Quadarax.Foundation.Core.Data.Interface.Entity;
- namespace Quadarax.Application.QLiberace.Base.Mapper
- {
- public static class MapperLongExt
- {
- public static TDto? Map<TDao, TDto>(this TDao? dao)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (dao == null) return null;
- return MapperLong.Instance.Map<TDao, TDto>(dao);
- }
-
- public static TDao? MapDto<TDto, TDao>(this TDto? dto)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (dto == null) return null;
- return MapperLong.Instance.Map<TDto, TDao>(dto);
- }
- public static TDtoResult? MapDto2Dto<TDto,TDtoResult>(this TDto? dto)
- where TDto : class, IDto, new()
- where TDtoResult : class, IDto, new()
- {
- if (dto == null) return null;
- return MapperLong.Instance.Map<TDto, TDtoResult>(dto);
- }
- public static void CopyToDto<TDto, TDao>(this TDto? @from, TDao? to)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (@from == null) return;
- if (to == null) return;
- MapperLong.Instance.Update(@from,to);
- }
- public static void CopyToDto<TDto, TDao>(this TDao? @from, TDto? to)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (to == null) return;
- if (@from == null) return;
- MapperLong.Instance.Update(@from,to);
- }
- public static List<TDto> MapList<TDao, TDto>(this IQueryable<TDao>? dao)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (dao == null) return new List<TDto>();
- return MapperLong.Instance.MapList<TDao, TDto>(dao);
- }
- public static List<TDto> MapList<TDao, TDto>(this IEnumerable<TDao>? dao)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (dao == null) return new List<TDto>();
- return MapperLong.Instance.MapList<TDao, TDto>(dao);
- }
- public static List<TDto> MapList<TDao, TDto>(this IList<TDao>? dao)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (dao == null) return new List<TDto>();
- return MapperLong.Instance.MapList<TDao, TDto>(dao);
- }
- public static IQueryable<TDao> MapListDto<TDto,TDao>(this IEnumerable<TDto>? dto)
- where TDao : class, IDao<long>, new()
- where TDto : class, IDto, new()
- {
- if (dto == null) return new List<TDao>().AsQueryable();
- return MapperLong.Instance.MapList<TDto, TDao>(dto.AsQueryable()).AsQueryable();
- }
- }
- }
|