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 System;
  7. using Abp.AutoMapper;
  8. using System.ComponentModel.DataAnnotations;
  9. using IwbZeroCore.AppServiceBase;
  10. using IwbZeroCore.Zero;
  11. namespace <#=Model.ApplicationNamespace#>.Dto
  12. {
  13. <#
  14. if(!string.IsNullOrEmpty(Model.HtmlPageTitle)){
  15. #>
  16. /// <summary>
  17. /// <#=Model.HtmlPageTitle#>
  18. /// </summary>
  19. <# }
  20. #> [AutoMapTo(typeof(<#=Model.ClassName#>))]
  21. <#if(Model.IdType=="string"){
  22. #>
  23. public class <#=Model.FileName#>CreateDto:IwbEntityDto
  24. <# }else{
  25. #>
  26. public class <#=Model.FileName#>CreateDto:IwbEntityDto<<#=Model.IdType#>>
  27. <#}
  28. #>
  29. {
  30. <#
  31. foreach (var item in Model.Columns)
  32. {
  33. if(!item.IsGenreated) continue;
  34. if(!string.IsNullOrEmpty(item.Comment)){
  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. }