LocalDB.tt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <#@ template debug="true" hostspecific="true" language="C#" #>
  2. <#@ assembly name="System.Core" #>
  3. <#@ assembly name="System.Data" #>
  4. <#@ assembly name="$(SolutionDir)\Lib\SCADA.CommonLib.dll" #>
  5. <#@ assembly name="$(SolutionDir)\Lib\System.Data.SQLite.dll" #>
  6. <#@ import namespace="System.Linq" #>
  7. <#@ import namespace="System.Text" #>
  8. <#@ import namespace="System.Collections.Generic" #>
  9. <#@ import namespace="System.Data" #>
  10. <#@ import namespace="SCADA.CommonLib.Data"#>
  11. <#@ import namespace="SCADA.CommonLib.Data.DIL"#>
  12. <#@ import namespace="SCADA.CommonLib.Data.DIL.MSSql"#>
  13. <#@ import namespace="SCADA.CommonLib.Data.DIL.MySql"#>
  14. <#@ import namespace="SCADA.CommonLib.Data.DIL.Sqlite"#>
  15. <#@ import namespace="SCADA.CommonLib.Data.DIL.Oracle"#>
  16. <#@ import namespace="SCADA.CommonLib.Data.DIL.NpgSql"#>
  17. <#@ import namespace="SCADA.CommonLib.Data.DIL.Sqlite"#>
  18. <#@ import namespace="Microsoft.VisualStudio.TextTemplating"#>
  19. <#@ output extension=".cs" #>
  20. <#
  21. string ttpath = this.Host.TemplateFile;
  22. string projectPath=Host.ResolveAssemblyReference("$(SolutionDir)");
  23. string outPath=Host.ResolveAssemblyReference("$(TargetDir)");
  24. // IDB db=new SQLDB("127.0.0.1,1433","EICP","sa","123456");
  25. // IDB db=new OracleDB("127.0.0.1:1521","EICP","sa","123456");
  26. // IDB db=new MySQLDB("127.0.0.1:3306","EICP","sa","123456");
  27. string dataPath=@$"{projectPath}\SCADA_DAQ\bin\Debug\net47\Data";
  28. IDB db=new SQLiteDB(dataPath,"LocalApp.db");
  29. #>
  30. using System;
  31. using System.Collections.Generic;
  32. using System.Linq.Expressions;
  33. using SCADA.CommonLib;
  34. using SCADA.CommonLib.Data;
  35. using SCADA.CommonLib.Data.DIL;
  36. <#if(db is SQLDB)
  37. {
  38. WriteLine("using System.Data.SqlClient;");
  39. WriteLine("using SCADA.CommonLib.Data.DIL.MSSql;");
  40. }
  41. else if(db is MySQLDB)
  42. {
  43. WriteLine("using SCADA.CommonLib.Data.DIL.MySql;");
  44. }
  45. else if(db is SQLiteDB)
  46. {
  47. WriteLine("using SCADA.CommonLib.Data.DIL.Sqlite;");
  48. }
  49. else if(db is OracleDB)
  50. {
  51. WriteLine("using SCADA.CommonLib.Data.DIL.Oracle;");
  52. }
  53. else if(db is NpgSQLDB)
  54. {
  55. WriteLine("using SCADA.CommonLib.Data.DIL.NpgSql;");
  56. }
  57. #>
  58. namespace LocalDB
  59. {
  60. namespace DBSchema
  61. {
  62. <#= db.GetProduceDefine() #>
  63. }
  64. namespace DBNames
  65. {
  66. <#=db.GetTableColumnsDefine() #>
  67. <#=db.GetViewColumnsDefine() #>
  68. <#=db.GetProduceParametersDefine() #>
  69. }
  70. namespace DBModel
  71. {
  72. <#= db.GetDBModel() #>
  73. }
  74. namespace DIL
  75. {
  76. <#if(db is SQLDB)
  77. {
  78. WriteLine(" public class DILDB:SQLDB");
  79. }
  80. else if(db is MySQLDB)
  81. {
  82. WriteLine(" public class DILDB:MySQLDB");
  83. }
  84. else if(db is SQLiteDB)
  85. {
  86. WriteLine(" public class DILDB:SQLiteDB");
  87. }
  88. else if(db is OracleDB)
  89. {
  90. WriteLine(" public class DILDB:OracleDB");
  91. }
  92. else if(db is NpgSQLDB)
  93. {
  94. WriteLine(" public class DILDB:NpgSQLDB");
  95. }
  96. #>
  97. {
  98. <#= db.GetDeclare() #>
  99. }
  100. }
  101. }