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() { if (dao == null) return null; return Mapper.Instance.Map(dao); } public static TDao MapDto(this TDto dto) where TDao : class, IDao, new() where TDto : class, IDto, new() { if (dto == null) return null; 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 (@from == null) return; 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; if (@from == null) return; Mapper.Instance.Update(@from,to); } public static List MapList(this IQueryable dao) where TDao : class, IDao, new() where TDto : class, IDto, new() { if (dao == null) return new List(); return Mapper.Instance.MapList(dao); } public static List MapList(this IEnumerable dao) where TDao : class, IDao, new() where TDto : class, IDto, new() { if (dao == null) return new List(); return Mapper.Instance.MapList(dao); } public static IQueryable MapListDto(this IEnumerable dto) where TDao : class, IDao, new() where TDto : class, IDto, new() { if (dto == null) return new List().AsQueryable(); return Mapper.Instance.MapList(dto.AsQueryable()).AsQueryable(); } } }