NullableIdDto.cs 873 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. namespace Abp.Application.Services.Dto
  3. {
  4. /// <summary>
  5. /// This DTO can be directly used (or inherited)
  6. /// to pass an nullable Id value to an application service method.
  7. /// </summary>
  8. /// <typeparam name="TId">Type of the Id</typeparam>
  9. [Serializable]
  10. public class NullableIdDto<TId>
  11. where TId : struct
  12. {
  13. public TId? Id { get; set; }
  14. public NullableIdDto()
  15. {
  16. }
  17. public NullableIdDto(TId? id)
  18. {
  19. Id = id;
  20. }
  21. }
  22. /// <summary>
  23. /// A shortcut of <see cref="NullableIdDto{TId}"/> for <see cref="int"/>.
  24. /// </summary>
  25. [Serializable]
  26. public class NullableIdDto : NullableIdDto<int>
  27. {
  28. public NullableIdDto()
  29. {
  30. }
  31. public NullableIdDto(int? id)
  32. : base(id)
  33. {
  34. }
  35. }
  36. }