Update 人大金仓 demo

This commit is contained in:
sunkaixuan 2024-07-10 21:15:51 +08:00
parent 3a805c7f39
commit 14d1e87ca9
38 changed files with 140 additions and 53 deletions

View File

@ -2,7 +2,7 @@
<package > <package >
<metadata> <metadata>
<id>SqlSugarCore.Kdbndp</id> <id>SqlSugarCore.Kdbndp</id>
<version>9.3.6.412</version> <version>9.3.6.618</version>
<authors>sunkaixuan</authors> <authors>sunkaixuan</authors>
<owners>果糖大数据科技</owners> <owners>果糖大数据科技</owners>
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl> <licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>

View File

@ -6,7 +6,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.6.412" /> <PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.6.618" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,4 +1,6 @@
using SqlSugar; using Kdbndp;
using KdbndpTypes;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
@ -29,7 +31,7 @@ namespace OrmTest
Console.WriteLine(""); Console.WriteLine("");
Console.WriteLine("#### Examples Start ####"); Console.WriteLine("#### Examples Start ####");
var db = GetInstance(); var db = GetInstance();
var dbTime = db.GetDate(); var dbTime = db.GetDate();
var getAll = db.Queryable<Order>().ToList(); var getAll = db.Queryable<Order>().ToList();
var getOrderBy = db.Queryable<Order>().OrderBy(it => it.Name,OrderByType.Desc).ToList(); var getOrderBy = db.Queryable<Order>().OrderBy(it => it.Name,OrderByType.Desc).ToList();
var getOrderBy2 = db.Queryable<Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList(); var getOrderBy2 = db.Queryable<Order>().OrderBy(it => it.Id).OrderBy(it => it.Name, OrderByType.Desc).ToList();

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using OrmTest;
namespace KdbndpTest.OracleDemo
{
internal class OracleDemo
{
public static void Init()
{
Demo0_SqlSugarClient.Init();
Demo1_Queryable.Init();
Demo2_Updateable.Init();
Demo3_Insertable.Init();
Demo4_Deleteable.Init();
Demo5_SqlQueryable.Init();
Demo6_Queue.Init();
Demo7_Ado.Init();
Demo8_Saveable.Init();
Demo9_EntityMain.Init();
DemoA_DbMain.Init();
DemoB_Aop.Init();
DemoC_GobalFilter.Init();
DemoD_DbFirst.Init(); ;
DemoE_CodeFirst.Init();
DemoF_Utilities.Init();
DemoG_SimpleClient.Init();
}
}
}

View File

@ -1,4 +1,5 @@
using SqlSugar; using KdbndpTest.OracleDemo.UnitTest;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using KdbndpTest.OracleDemo.UnitTest;
namespace OrmTest namespace OrmTest
{ {

View File

@ -1,4 +1,5 @@
using SqlSugar; using OrmTest;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data.SqlTypes; using System.Data.SqlTypes;
@ -7,7 +8,7 @@ using System.Security.Principal;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OrmTest namespace KdbndpTest.OracleDemo.UnitTest
{ {
internal class UInsert3 internal class UInsert3
{ {
@ -71,10 +72,10 @@ namespace OrmTest
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
public decimal Price { get; set; } public decimal Price { get; set; }
[SugarColumn(InsertServerTime =true,UpdateServerTime =true)] [SugarColumn(InsertServerTime = true, UpdateServerTime = true)]
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public int CustomId { get; set; } public int CustomId { get; set; }
} }
public class ORDER public class ORDER
@ -86,7 +87,7 @@ namespace OrmTest
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
public decimal Price { get; set; } public decimal Price { get; set; }
[SugarColumn(InsertSql = "'2020-1-1'",UpdateSql = "'2022-1-1'")] [SugarColumn(InsertSql = "'2020-1-1'", UpdateSql = "'2022-1-1'")]
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public int CustomId { get; set; } public int CustomId { get; set; }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using KdbndpTest.OracleDemo.UnitTest;
namespace OrmTest namespace OrmTest
{ {

View File

@ -1,4 +1,5 @@
using SqlSugar; using KdbndpTest.OracleDemo.UnitTest;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using KdbndpTest.OracleDemo.UnitTest;
using SqlSugar; using SqlSugar;
namespace OrmTest namespace OrmTest
{ {

View File

@ -4,13 +4,13 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OrmTest namespace KdbndpTest.OracleDemo.UnitTest
{ {
public class UValidate public class UValidate
{ {
public static void Check(object a, object b, object name) public static void Check(object a, object b, object name)
{ {
if (a?.ToString()?.Replace(" ","").Trim().ToLower() != b?.ToString().Replace(" ", "")?.Trim().ToLower()) if (a?.ToString()?.Replace(" ", "").Trim().ToLower() != b?.ToString().Replace(" ", "")?.Trim().ToLower())
{ {
throw new Exception(name + " error"); throw new Exception(name + " error");
} }

View File

@ -1,15 +1,16 @@
using SqlSugar; using OrmTest;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OrmTest namespace KdbndpTest.OracleDemo.UnitTest
{ {
internal class UnitDateTime internal class UnitDateTime
{ {
public static void Init() public static void Init()
{ {
Console.WriteLine(""); Console.WriteLine("");
Console.WriteLine("#### DateTime Start ####"); Console.WriteLine("#### DateTime Start ####");
@ -20,8 +21,9 @@ namespace OrmTest
ConnectionString = Config.ConnectionString.Replace("59321", "59322"), ConnectionString = Config.ConnectionString.Replace("59321", "59322"),
InitKeyType = InitKeyType.Attribute, InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true, IsAutoCloseConnection = true,
MoreSettings=new ConnMoreSettings() { MoreSettings = new ConnMoreSettings()
DatabaseModel=DbType.MySql {
DatabaseModel = DbType.MySql
}, },
AopEvents = new AopEvents AopEvents = new AopEvents
{ {
@ -33,10 +35,10 @@ namespace OrmTest
} }
}); });
var dt=db.Ado.GetDataTable("show database_mode;"); var dt = db.Ado.GetDataTable("show database_mode;");
var now = DateTime.Now; var now = DateTime.Now;
var insertObj = new UnitOrderDateTest() { Id = 1, Name = "0",CreateTime= now }; var insertObj = new UnitOrderDateTest() { Id = 1, Name = "0", CreateTime = now };
var insertObj2 = new List<UnitOrderDateTest> var insertObj2 = new List<UnitOrderDateTest>
{ {
new UnitOrderDateTest() { Id = 11, Name = "1ms",CreateTime=now.AddMilliseconds(1) }, new UnitOrderDateTest() { Id = 11, Name = "1ms",CreateTime=now.AddMilliseconds(1) },
@ -52,7 +54,7 @@ namespace OrmTest
var beginTime = now.AddMinutes(-2); var beginTime = now.AddMinutes(-2);
var endTime = now.AddHours(1).AddMinutes(2); var endTime = now.AddHours(1).AddMinutes(2);
var list=db.Queryable<UnitOrderDateTest>().Where(it => it.CreateTime >= beginTime var list = db.Queryable<UnitOrderDateTest>().Where(it => it.CreateTime >= beginTime
&& it.CreateTime <= endTime) && it.CreateTime <= endTime)
.ToList(); .ToList();
@ -60,24 +62,24 @@ namespace OrmTest
&& it.CreateTime <= endTime) && it.CreateTime <= endTime)
.ToSqlString(); .ToSqlString();
var list2=db.Ado.SqlQuery<UnitOrderDateTest>(sql); var list2 = db.Ado.SqlQuery<UnitOrderDateTest>(sql);
if (list.Count() != 5 || list2.Count() != 5) if (list.Count() != 5 || list2.Count() != 5)
{ {
throw new Exception("UnitDateTime Error"); throw new Exception("UnitDateTime Error");
} }
Console.WriteLine("#### DateTime End ####"); Console.WriteLine("#### DateTime End ####");
} }
public class UnitOrderDateTest public class UnitOrderDateTest
{ {
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)] [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; } public int Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
[SugarColumn(IsNullable = true)] [SugarColumn(IsNullable = true)]
public DateTime CreateTime { get; set; } public DateTime CreateTime { get; set; }
} }
} }
} }

View File

@ -1,16 +1,17 @@
using SqlSugar; using OrmTest;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace OrmTest namespace KdbndpTest.OracleDemo.UnitTest
{ {
internal class UnitSplitTask internal class UnitSplitTask
{ {
public static void Init() public static void Init()
{ {
var client = NewUnitTest.Db; var client = NewUnitTest.Db;
Console.WriteLine("Hello, World!"); Console.WriteLine("Hello, World!");
List<Task> tasks = new List<Task>() List<Task> tasks = new List<Task>()
{ {
@ -19,14 +20,15 @@ namespace OrmTest
CreateTask(client.CopyNew()) CreateTask(client.CopyNew())
}; };
Task.WhenAll(tasks).GetAwaiter().GetResult(); Task.WhenAll(tasks).GetAwaiter().GetResult();
client.Deleteable(new SpitDemoModel()).SplitTable().ExecuteCommand(); client.Deleteable(new SpitDemoModel()).SplitTable().ExecuteCommand();
} }
private static Task CreateTask(ISqlSugarClient client) private static Task CreateTask(ISqlSugarClient client)
{ {
return Task.Run(() => { return Task.Run(() =>
{
client.Insertable(new SpitDemoModel()).SplitTable().ExecuteCommand(); client.Insertable(new SpitDemoModel()).SplitTable().ExecuteCommand();
}); });
} }
@ -43,4 +45,4 @@ namespace OrmTest
} }
} }

View File

@ -1,4 +1,5 @@
using SqlSugar; using KdbndpTest.OracleDemo.UnitTest;
using SqlSugar;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

View File

@ -1,4 +1,6 @@
using System; using KdbndpTest.OracleDemo;
using KdbndpTest.SqlServerDemo;
using System;
namespace OrmTest namespace OrmTest
{ {
@ -6,24 +8,12 @@ namespace OrmTest
{ {
static void Main(string[] args) static void Main(string[] args)
{ {
//Demo
Demo0_SqlSugarClient.Init(); //Oracle模式DEMO
Demo1_Queryable.Init(); OracleDemo.Init();
Demo2_Updateable.Init();
Demo3_Insertable.Init(); //SqlServer模式DEMO
Demo4_Deleteable.Init(); SqlServer.Init();
Demo5_SqlQueryable.Init();
Demo6_Queue.Init();
Demo7_Ado.Init();
Demo8_Saveable.Init();
Demo9_EntityMain.Init();
DemoA_DbMain.Init();
DemoB_Aop.Init();
DemoC_GobalFilter.Init();
DemoD_DbFirst.Init(); ;
DemoE_CodeFirst.Init();
DemoF_Utilities.Init();
DemoG_SimpleClient.Init();
//Unit test //Unit test
//NewUnitTest.Init(); //NewUnitTest.Init();

View File

@ -0,0 +1,51 @@
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();
}
}
}