CreateDto.tt 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. <#if(Model.IdType=="string"){
  21. #>
  22. public class <#=Model.FileName#>CreateDto:IwbEntityDto
  23. <# }else{
  24. #>
  25. public class <#=Model.FileName#>CreateDto:IwbEntityDto<<#=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. #> /// <summary>
  35. /// <#=item.Comment#>
  36. /// </summary>
  37. <# }
  38. if (item.IsRequired)
  39. {
  40. #> [Required]
  41. <# }
  42. var maxLength="";
  43. if (item.IsVarchar && !string.IsNullOrEmpty(item.MaxLength))
  44. {
  45. maxLength=item.MaxLength.StartsWith(".")?Model.ClassName+item.MaxLength:item.MaxLength;
  46. }
  47. if(!string.IsNullOrEmpty(maxLength))
  48. {
  49. #> [StringLength(<#=maxLength#>)]
  50. <# }
  51. #> public <#=item.AttrType#> <#=item.ColumnName#> { get; set; }
  52. <#
  53. }
  54. #>
  55. }
  56. }