CreateDto.tt 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <#@ template language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ import namespace="System.Linq" #>
  4. <#@ import namespace="System.Text" #>
  5. <#@ import namespace="System.Collections.Generic" #>
  6. using System;
  7. using Abp.AutoMapper;
  8. using System.ComponentModel.DataAnnotations;
  9. using IwbZero.AppServiceBase;
  10. namespace <#=Model.ApplicationNamespace#>.Dto
  11. {
  12. <#
  13. if(!string.IsNullOrEmpty(Model.HtmlPageTitle)){
  14. #>
  15. /// <summary>
  16. /// <#=Model.HtmlPageTitle#>
  17. /// </summary>
  18. <# }
  19. #> [AutoMapTo(typeof(<#=Model.ClassName#>))]
  20. public class <#=Model.ClassName#>CreateDto:IwbEntityDto<<#=Model.IdType#>>
  21. {
  22. <#
  23. foreach (var item in Model.Columns)
  24. {
  25. if(!item.IsGenreated) continue;
  26. if(!string.IsNullOrEmpty(item.Comment)){
  27. #> /// <summary>
  28. /// <#=item.Comment#>
  29. /// </summary>
  30. <# }
  31. if (item.IsRequired)
  32. {
  33. #> [Required]
  34. <# }
  35. var maxLength="";
  36. if (item.IsVarchar && !string.IsNullOrEmpty(item.MaxLength))
  37. {
  38. maxLength=item.MaxLength.StartsWith(".")?Model.ClassName+item.MaxLength:item.MaxLength;
  39. }
  40. if(!string.IsNullOrEmpty(maxLength))
  41. {
  42. #> [StringLength(<#=maxLength#>)]
  43. <# }
  44. #> public <#=item.AttrType#> <#=item.ColumnName#> { get; set; }
  45. <#
  46. }
  47. #>
  48. }
  49. }