DtoExt.cs 803 B

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