CreateDto.tt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 Abp.AutoMapper;
  7. using System;
  8. using System.ComponentModel.DataAnnotations;
  9. using VberZero.AppService.Base.Dto;
  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. <#if(Model.IdType=="string"){
  21. #>
  22. public class <#=Model.FileName#>CreateDto:VzEntityDto
  23. <# }else{
  24. #>
  25. public class <#=Model.FileName#>CreateDto:VzEntityDto<<#=Model.IdType#>?>
  26. <#}
  27. #>
  28. {
  29. <#
  30. foreach (var item in Model.Columns)
  31. {
  32. if(!item.IsGenreated) continue;
  33. if(!string.IsNullOrEmpty(item.Comment)){
  34. #>
  35. /// <summary>
  36. /// <#=item.Comment#>
  37. /// </summary>
  38. <# }
  39. if (item.IsRequired)
  40. {
  41. #> [Required]
  42. <# }
  43. var maxLength="";
  44. if (item.IsVarchar && !string.IsNullOrEmpty(item.MaxLength))
  45. {
  46. maxLength=item.MaxLength.StartsWith(".")?Model.ClassName+item.MaxLength:item.MaxLength;
  47. }
  48. if(!string.IsNullOrEmpty(maxLength))
  49. {
  50. #> [StringLength(<#=maxLength#>)]
  51. <# }
  52. #> public <#=item.AttrType#> <#=item.ColumnName#> { get; set; }
  53. <#
  54. }
  55. #>
  56. }
  57. }