You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
4.0 KiB

2 years ago
  1. namespace SqlSugar
  2. {
  3. public class DbFirstTemplate
  4. {
  5. #region Template
  6. public static string ClassTemplate = "{using}\r\n" +
  7. "namespace {Namespace}\r\n" +
  8. "{\r\n" +
  9. "{ClassDescription}{SugarTable}\r\n" +
  10. ClassSpace + "public partial class {ClassName} : ModelContext\r\n" +
  11. ClassSpace + "{\r\n" +
  12. PropertySpace + "public {ClassName}(){\r\n\r\n" +
  13. "{Constructor}\r\n" +
  14. PropertySpace + "}\r\n" +
  15. //PropertySpace + "[SugarColumn(IsIgnore = true)]\r\n" +
  16. //PropertySpace + "public int RowIndex { get; set; }\r\n" +
  17. "{PropertyName}\r\n" +
  18. ClassSpace + "}\r\n" +
  19. "}\r\n";
  20. public static string ClassDescriptionTemplate =
  21. ClassSpace + "///<summary>\r\n" +
  22. ClassSpace + "///{ClassDescription}" +
  23. ClassSpace + "///</summary>";
  24. public static string PropertyTemplate = PropertySpace + "{SugarColumn}\r\n" +
  25. PropertySpace + "public {PropertyType} {PropertyName} {get;set;}\r\n";
  26. public static string PropertyConstNameTemplate = PropertySpace + "public const string CN_{CN_PropertyName} = \"{PropertyName}\";\r\n";
  27. public static string PropertyDescriptionTemplate =
  28. PropertySpace + "/// <summary>\r\n" +
  29. PropertySpace + "/// Desc:{PropertyDescription}\r\n" +
  30. PropertySpace + "/// Default:{DefaultValue}\r\n" +
  31. PropertySpace + "/// Nullable:{IsNullable}\r\n" +
  32. PropertySpace + "/// </summary>";
  33. public static string ConstructorTemplate = PropertySpace + " this.{PropertyName} ={DefaultValue};\r\n";
  34. public static string UsingTemplate = "using System;\r\n" +
  35. "using System.Linq;\r\n" +
  36. "using System.Text;" + "\r\n";
  37. #endregion Template
  38. #region Replace Key
  39. public const string KeyUsing = "{using}";
  40. public const string KeyNamespace = "{Namespace}";
  41. public const string KeyClassName = "{ClassName}";
  42. public const string KeyIsNullable = "{IsNullable}";
  43. public const string KeySugarTable = "{SugarTable}";
  44. public const string KeyConstructor = "{Constructor}";
  45. public const string KeySugarColumn = "{SugarColumn}";
  46. public const string KeyPropertyType = "{PropertyType}";
  47. public const string KeyPropertyName = "{PropertyName}";
  48. public const string KeyPropertyConstName = "{CN_PropertyName}";
  49. public const string KeyDefaultValue = "{DefaultValue}";
  50. public const string KeyClassDescription = "{ClassDescription}";
  51. public const string KeyPropertyDescription = "{PropertyDescription}";
  52. #endregion Replace Key
  53. #region Replace Value
  54. public const string ValueSugarTable = "\r\n" + ClassSpace + "[SugarTable(\"{0}\")]";
  55. public const string ValueSugarCoulmn = "\r\n" + PropertySpace + "[SugarColumn({0})]";
  56. #endregion Replace Value
  57. #region Space
  58. public const string PropertySpace = " ";
  59. public const string ClassSpace = " ";
  60. #endregion Space
  61. }
  62. }