mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
人大金仓 DEMO
This commit is contained in:
parent
a54ff44080
commit
4999b6254a
@ -13,9 +13,4 @@
|
|||||||
<ProjectReference Include="..\SqlSugar\SqlSugar.csproj" />
|
<ProjectReference Include="..\SqlSugar\SqlSugar.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Folder Include="PgSqlDemo\" />
|
|
||||||
<Folder Include="MySqlDemo\" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
65
Src/Asp.NetCore2/KdbndpTest/MySqlDemo/MySql.cs
Normal file
65
Src/Asp.NetCore2/KdbndpTest/MySqlDemo/MySql.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
Src/Asp.NetCore2/KdbndpTest/PgSqlDemo/PgSql.cs
Normal file
65
Src/Asp.NetCore2/KdbndpTest/PgSqlDemo/PgSql.cs
Normal 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,12 +8,20 @@ namespace OrmTest
|
|||||||
{
|
{
|
||||||
static void Main(string[] args)
|
static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
//可以查看安装的模式
|
||||||
|
//show database_mode;
|
||||||
|
|
||||||
//Oracle模式DEMO
|
//Oracle模式DEMO 【默认模式:语法同时支持PGSQL】
|
||||||
OracleDemo.Init();
|
OracleDemo.Init();
|
||||||
|
|
||||||
//SqlServer模式DEMO
|
//SqlServer模式DEMO
|
||||||
SqlServer.Init();
|
SqlServerDemo.Init();
|
||||||
|
|
||||||
|
//MySql模式DEMO
|
||||||
|
MySqlDemo.Init();
|
||||||
|
|
||||||
|
//PostgreSQL模式DEMO
|
||||||
|
PgSqlDemo.Init();
|
||||||
|
|
||||||
//Unit test
|
//Unit test
|
||||||
//NewUnitTest.Init();
|
//NewUnitTest.Init();
|
||||||
|
@ -8,7 +8,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace KdbndpTest.SqlServerDemo
|
namespace KdbndpTest.SqlServerDemo
|
||||||
{
|
{
|
||||||
internal class SqlServer
|
internal class SqlServerDemo
|
||||||
{
|
{
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user