diff --git a/Src/Asp.NetCore2/KdbndpTest/KdbndpTest.csproj b/Src/Asp.NetCore2/KdbndpTest/KdbndpTest.csproj index 37adfb590..b44ea2f45 100644 --- a/Src/Asp.NetCore2/KdbndpTest/KdbndpTest.csproj +++ b/Src/Asp.NetCore2/KdbndpTest/KdbndpTest.csproj @@ -13,9 +13,4 @@ - - - - - diff --git a/Src/Asp.NetCore2/KdbndpTest/MySqlDemo/MySql.cs b/Src/Asp.NetCore2/KdbndpTest/MySqlDemo/MySql.cs new file mode 100644 index 000000000..67ccb593a --- /dev/null +++ b/Src/Asp.NetCore2/KdbndpTest/MySqlDemo/MySql.cs @@ -0,0 +1,65 @@ +using OrmTest; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KdbndpTest.SqlServerDemo +{ + internal class MySqlDemo + { + public static void Init() + { + SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.Kdbndp, + ConnectionString = "Server=211.95.20.236 ;Port=35052;UID=system;PWD=abc123;database=test222", + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + MoreSettings=new ConnMoreSettings() { + DatabaseModel=DbType.MySql + } + }, db => { + db.Aop.OnLogExecuting = (sql, p) => + { + Console.WriteLine(sql); + Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value))); + }; + }); + Db.DbMaintenance.CreateDatabase(); + + foreach (var item in Db.DbMaintenance.GetColumnInfosByTableName("order",false)) + { + Console.WriteLine($"{item.DbColumnName} DataType:{item.DataType} IsIdentity :{item.IsIdentity} IsPrimarykey :{item.IsPrimarykey} IsNullable: {item.IsNullable} Length:{item.Length} Scale:{item.Scale}"); + } + + var yyy = Db.Queryable().ToList(); + var xxx=Db.Ado.GetDataTable("select 1 as id"); + + Db.CodeFirst.InitTables(); + Db.Insertable(new Order() + { + CreateTime=DateTime.Now, + CustomId=1, + Name="a", + Price=1 + }).ExecuteCommand(); + Db.Updateable(new Order() + { + CreateTime = DateTime.Now, + CustomId = 1, + Name = "a", + Price = 1 + }).ExecuteCommand(); + Db.Deleteable(new Order() + { + CreateTime = DateTime.Now, + CustomId = 1, + Name = "a", + Price = 1 + }).ExecuteCommand(); + } + } +} diff --git a/Src/Asp.NetCore2/KdbndpTest/PgSqlDemo/PgSql.cs b/Src/Asp.NetCore2/KdbndpTest/PgSqlDemo/PgSql.cs new file mode 100644 index 000000000..eced106b1 --- /dev/null +++ b/Src/Asp.NetCore2/KdbndpTest/PgSqlDemo/PgSql.cs @@ -0,0 +1,65 @@ +using OrmTest; +using SqlSugar; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace KdbndpTest.SqlServerDemo +{ + internal class PgSqlDemo + { + public static void Init() + { + SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig() + { + DbType = DbType.Kdbndp, + ConnectionString = "Server=211.95.20.236 ;Port=35052;UID=system;PWD=abc123;database=test222", + InitKeyType = InitKeyType.Attribute, + IsAutoCloseConnection = true, + MoreSettings=new ConnMoreSettings() { + DatabaseModel=DbType.PostgreSQL + } + }, db => { + db.Aop.OnLogExecuting = (sql, p) => + { + Console.WriteLine(sql); + Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value))); + }; + }); + Db.DbMaintenance.CreateDatabase(); + + foreach (var item in Db.DbMaintenance.GetColumnInfosByTableName("order",false)) + { + Console.WriteLine($"{item.DbColumnName} DataType:{item.DataType} IsIdentity :{item.IsIdentity} IsPrimarykey :{item.IsPrimarykey} IsNullable: {item.IsNullable} Length:{item.Length} Scale:{item.Scale}"); + } + + var yyy = Db.Queryable().ToList(); + var xxx=Db.Ado.GetDataTable("select 1 as id"); + + Db.CodeFirst.InitTables(); + Db.Insertable(new Order() + { + CreateTime=DateTime.Now, + CustomId=1, + Name="a", + Price=1 + }).ExecuteCommand(); + Db.Updateable(new Order() + { + CreateTime = DateTime.Now, + CustomId = 1, + Name = "a", + Price = 1 + }).ExecuteCommand(); + Db.Deleteable(new Order() + { + CreateTime = DateTime.Now, + CustomId = 1, + Name = "a", + Price = 1 + }).ExecuteCommand(); + } + } +} diff --git a/Src/Asp.NetCore2/KdbndpTest/Program.cs b/Src/Asp.NetCore2/KdbndpTest/Program.cs index b1e4f2c56..1f5732c99 100644 --- a/Src/Asp.NetCore2/KdbndpTest/Program.cs +++ b/Src/Asp.NetCore2/KdbndpTest/Program.cs @@ -8,12 +8,20 @@ namespace OrmTest { static void Main(string[] args) { + //可以查看安装的模式 + //show database_mode; - //Oracle模式DEMO + //Oracle模式DEMO 【默认模式:语法同时支持PGSQL】 OracleDemo.Init(); //SqlServer模式DEMO - SqlServer.Init(); + SqlServerDemo.Init(); + + //MySql模式DEMO + MySqlDemo.Init(); + + //PostgreSQL模式DEMO + PgSqlDemo.Init(); //Unit test //NewUnitTest.Init(); diff --git a/Src/Asp.NetCore2/KdbndpTest/SqlServerDemo/SqlServer.cs b/Src/Asp.NetCore2/KdbndpTest/SqlServerDemo/SqlServer.cs index 555503576..617266657 100644 --- a/Src/Asp.NetCore2/KdbndpTest/SqlServerDemo/SqlServer.cs +++ b/Src/Asp.NetCore2/KdbndpTest/SqlServerDemo/SqlServer.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace KdbndpTest.SqlServerDemo { - internal class SqlServer + internal class SqlServerDemo { public static void Init() {