DtoExt.cs 717 B

123456789101112131415161718192021
  1. using System;
  2. using System.Collections.Generic;
  3. namespace Quadarax.Foundation.Core.Data.Interface.Entity.Dto.Extensions
  4. {
  5. public static class DtoExt
  6. {
  7. public static ResultValueDto<TDto> AsResult<TDto>(this TDto value) where TDto : IDto, new()
  8. {
  9. if (value == null)
  10. throw new ArgumentNullException(nameof(value));
  11. return new ResultValueDto<TDto>(value);
  12. }
  13. public static ResultsValueDto<TDto> AsResult<TDto>(this IEnumerable<TDto> values) where TDto : IDto
  14. {
  15. if (values == null)
  16. throw new ArgumentNullException(nameof(values));
  17. return new ResultsValueDto<TDto>(values);
  18. }
  19. }
  20. }