|
|
@@ -7,54 +7,48 @@ namespace Quadarax.Foundation.Core.Data.Mapper
|
|
|
{
|
|
|
public static class MapperGuidExt
|
|
|
{
|
|
|
- public static TDto Map<TDao, TDto>(this TDao dao)
|
|
|
+ public static TDto? Map<TDao, TDto>(this TDao dao)
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
- if (dao == null) return null;
|
|
|
return Mapper<MapperGuid>.Instance.Map<TDao, TDto>(dao);
|
|
|
}
|
|
|
|
|
|
- public static TDao MapDto<TDto, TDao>(this TDto dto)
|
|
|
+ public static TDao? MapDto<TDto, TDao>(this TDto dto)
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
- if (dto == null) return null;
|
|
|
return Mapper<MapperGuid>.Instance.Map<TDto, TDao>(dto);
|
|
|
}
|
|
|
|
|
|
- public static void CopyToDto<TDto, TDao>(this TDto @from, TDao to)
|
|
|
+ public static void CopyToDto<TDto, TDao>(this TDto @from, TDao? to)
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
- if (@from == null) return;
|
|
|
if (to == null) return;
|
|
|
Mapper<MapperGuid>.Instance.Update(@from,to);
|
|
|
}
|
|
|
|
|
|
- public static void CopyToDto<TDto, TDao>(this TDao @from, TDto to)
|
|
|
+ public static void CopyToDto<TDto, TDao>(this TDao @from, TDto? to)
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
if (to == null) return;
|
|
|
- if (@from == null) return;
|
|
|
Mapper<MapperGuid>.Instance.Update(@from,to);
|
|
|
}
|
|
|
|
|
|
|
|
|
- public static List<TDto> MapList<TDao, TDto>(this IQueryable<TDao> dao)
|
|
|
+ public static List<TDto>? MapList<TDao, TDto>(this IQueryable<TDao> dao)
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
- if (dao == null) return new List<TDto>();
|
|
|
return Mapper<MapperGuid>.Instance.MapList<TDao, TDto>(dao);
|
|
|
}
|
|
|
|
|
|
- public static List<TDto> MapList<TDao, TDto>(this IEnumerable<TDao> dao)
|
|
|
+ public static List<TDto>? MapList<TDao, TDto>(this IEnumerable<TDao> dao)
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
- if (dao == null) return new List<TDto>();
|
|
|
return Mapper<MapperGuid>.Instance.MapList<TDao, TDto>(dao);
|
|
|
}
|
|
|
|
|
|
@@ -62,8 +56,7 @@ namespace Quadarax.Foundation.Core.Data.Mapper
|
|
|
where TDao : class, IDao<Guid>, new()
|
|
|
where TDto : class, IDto, new()
|
|
|
{
|
|
|
- if (dto == null) return new List<TDao>().AsQueryable();
|
|
|
- return Mapper<MapperGuid>.Instance.MapList<TDto, TDao>(dto.AsQueryable()).AsQueryable();
|
|
|
+ return (Mapper<MapperGuid>.Instance.MapList<TDto, TDao>(dto?.AsQueryable()) ?? throw new InvalidOperationException()).AsQueryable();
|
|
|
}
|
|
|
|
|
|
}
|