人大金仓 DEMO

This commit is contained in:
sunkaixuan 2024-07-11 12:00:37 +08:00
parent a54ff44080
commit 4999b6254a
5 changed files with 141 additions and 8 deletions

View File

@ -13,9 +13,4 @@
<ProjectReference Include="..\SqlSugar\SqlSugar.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="PgSqlDemo\" />
<Folder Include="MySqlDemo\" />
</ItemGroup>
</Project>

View File

@ -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<Order>().ToList();
var xxx=Db.Ado.GetDataTable("select 1 as id");
Db.CodeFirst.InitTables<Order>();
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();
}
}
}

View File

@ -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<Order>().ToList();
var xxx=Db.Ado.GetDataTable("select 1 as id");
Db.CodeFirst.InitTables<Order>();
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();
}
}
}

View File

@ -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();

View File

@ -8,7 +8,7 @@ using System.Threading.Tasks;
namespace KdbndpTest.SqlServerDemo
{
internal class SqlServer
internal class SqlServerDemo
{
public static void Init()
{