using System; using System.Collections.Generic; using System.Linq; using Quadarax.Foundation.Core.Data.Interface.Entity; namespace Quadarax.Foundation.Core.Data.Mapper { public static class MapperGuidExt { public static TDto? Map(this TDao dao) where TDao : class, IDao, new() where TDto : class, IDto, new() { return Mapper.Instance.Map(dao); } public static TDao? MapDto(this TDto dto) where TDao : class, IDao, new() where TDto : class, IDto, new() { return Mapper.Instance.Map(dto); } public static void CopyToDto(this TDto @from, TDao? to) where TDao : class, IDao, new() where TDto : class, IDto, new() { if (to == null) return; Mapper.Instance.Update(@from,to); } public static void CopyToDto(this TDao @from, TDto? to) where TDao : class, IDao, new() where TDto : class, IDto, new() { if (to == null) return; Mapper.Instance.Update(@from,to); } public static List? MapList(this IQueryable dao) where TDao : class, IDao, new() where TDto : class, IDto, new() { return Mapper.Instance.MapList(dao); } public static List? MapList(this IEnumerable dao) where TDao : class, IDao, new() where TDto : class, IDto, new() { return Mapper.Instance.MapList(dao); } public static IQueryable MapListDto(this IEnumerable dto) where TDao : class, IDao, new() where TDto : class, IDto, new() { return (Mapper.Instance.MapList(dto?.AsQueryable()) ?? throw new InvalidOperationException()).AsQueryable(); } } }