mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-07 14:18:03 +08:00
52 lines
1.8 KiB
C#
52 lines
1.8 KiB
C#
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 SqlServer
|
|
{
|
|
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.SqlServer
|
|
}
|
|
}, 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 * from information_schema.columns where pg_catalog.UPPER(table_name)=pg_catalog.UPPER('ORDER')\r\n");
|
|
|
|
Db.CodeFirst.InitTables<Order>();
|
|
Db.Insertable(new Order()
|
|
{
|
|
CreateTime=DateTime.Now,
|
|
CustomId=1,
|
|
Name="a",
|
|
Price=1
|
|
}).ExecuteCommand();
|
|
}
|
|
}
|
|
}
|