mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 13:06:50 +08:00
Update 人大金仓 demo
This commit is contained in:
parent
3a805c7f39
commit
14d1e87ca9
Binary file not shown.
@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>SqlSugarCore.Kdbndp</id>
|
||||
<version>9.3.6.412</version>
|
||||
<version>9.3.6.618</version>
|
||||
<authors>sunkaixuan</authors>
|
||||
<owners>果糖大数据科技</owners>
|
||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||
|
@ -6,7 +6,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.6.412" />
|
||||
<PackageReference Include="SqlSugarCore.Kdbndp" Version="9.3.6.618" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,4 +1,6 @@
|
||||
using SqlSugar;
|
||||
using Kdbndp;
|
||||
using KdbndpTypes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
@ -29,7 +31,7 @@ namespace OrmTest
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("#### Examples Start ####");
|
||||
var db = GetInstance();
|
||||
var dbTime = db.GetDate();
|
||||
var dbTime = db.GetDate();
|
||||
var getAll = db.Queryable<Order>().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();
|
33
Src/Asp.NetCore2/KdbndpTest/OracleDemo/OracleDemo.cs
Normal file
33
Src/Asp.NetCore2/KdbndpTest/OracleDemo/OracleDemo.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using SqlSugar;
|
||||
using KdbndpTest.OracleDemo.UnitTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using KdbndpTest.OracleDemo.UnitTest;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
@ -1,4 +1,5 @@
|
||||
using SqlSugar;
|
||||
using OrmTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlTypes;
|
||||
@ -7,7 +8,7 @@ using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
namespace KdbndpTest.OracleDemo.UnitTest
|
||||
{
|
||||
internal class UInsert3
|
||||
{
|
||||
@ -71,10 +72,10 @@ namespace OrmTest
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
public decimal Price { get; set; }
|
||||
[SugarColumn(InsertServerTime =true,UpdateServerTime =true)]
|
||||
[SugarColumn(InsertServerTime = true, UpdateServerTime = true)]
|
||||
public DateTime CreateTime { get; set; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int CustomId { get; set; }
|
||||
public int CustomId { get; set; }
|
||||
}
|
||||
|
||||
public class ORDER
|
||||
@ -86,7 +87,7 @@ namespace OrmTest
|
||||
/// </summary>
|
||||
public string Name { 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; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public int CustomId { get; set; }
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using KdbndpTest.OracleDemo.UnitTest;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
@ -1,4 +1,5 @@
|
||||
using SqlSugar;
|
||||
using KdbndpTest.OracleDemo.UnitTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using KdbndpTest.OracleDemo.UnitTest;
|
||||
using SqlSugar;
|
||||
namespace OrmTest
|
||||
{
|
@ -4,13 +4,13 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
namespace KdbndpTest.OracleDemo.UnitTest
|
||||
{
|
||||
public class UValidate
|
||||
{
|
||||
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");
|
||||
}
|
@ -1,15 +1,16 @@
|
||||
using SqlSugar;
|
||||
using OrmTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
namespace KdbndpTest.OracleDemo.UnitTest
|
||||
{
|
||||
internal class UnitDateTime
|
||||
{
|
||||
public static void Init()
|
||||
public static void Init()
|
||||
{
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("#### DateTime Start ####");
|
||||
@ -20,8 +21,9 @@ namespace OrmTest
|
||||
ConnectionString = Config.ConnectionString.Replace("59321", "59322"),
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
IsAutoCloseConnection = true,
|
||||
MoreSettings=new ConnMoreSettings() {
|
||||
DatabaseModel=DbType.MySql
|
||||
MoreSettings = new ConnMoreSettings()
|
||||
{
|
||||
DatabaseModel = DbType.MySql
|
||||
},
|
||||
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 insertObj = new UnitOrderDateTest() { Id = 1, Name = "0",CreateTime= now };
|
||||
var insertObj = new UnitOrderDateTest() { Id = 1, Name = "0", CreateTime = now };
|
||||
var insertObj2 = new List<UnitOrderDateTest>
|
||||
{
|
||||
new UnitOrderDateTest() { Id = 11, Name = "1ms",CreateTime=now.AddMilliseconds(1) },
|
||||
@ -52,7 +54,7 @@ namespace OrmTest
|
||||
|
||||
var beginTime = now.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)
|
||||
.ToList();
|
||||
|
||||
@ -60,24 +62,24 @@ namespace OrmTest
|
||||
&& it.CreateTime <= endTime)
|
||||
.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");
|
||||
}
|
||||
|
||||
Console.WriteLine("#### DateTime End ####");
|
||||
Console.WriteLine("#### DateTime End ####");
|
||||
}
|
||||
public class UnitOrderDateTest
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int Id { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Name { get; set; }
|
||||
[SugarColumn(IsNullable = true)]
|
||||
public DateTime CreateTime { get; set; }
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,17 @@
|
||||
using SqlSugar;
|
||||
using OrmTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
namespace KdbndpTest.OracleDemo.UnitTest
|
||||
{
|
||||
internal class UnitSplitTask
|
||||
{
|
||||
public static void Init()
|
||||
public static void Init()
|
||||
{
|
||||
var client = NewUnitTest.Db;
|
||||
var client = NewUnitTest.Db;
|
||||
Console.WriteLine("Hello, World!");
|
||||
List<Task> tasks = new List<Task>()
|
||||
{
|
||||
@ -19,14 +20,15 @@ namespace OrmTest
|
||||
CreateTask(client.CopyNew())
|
||||
};
|
||||
|
||||
Task.WhenAll(tasks).GetAwaiter().GetResult();
|
||||
Task.WhenAll(tasks).GetAwaiter().GetResult();
|
||||
client.Deleteable(new SpitDemoModel()).SplitTable().ExecuteCommand();
|
||||
}
|
||||
|
||||
|
||||
private static Task CreateTask(ISqlSugarClient client)
|
||||
{
|
||||
return Task.Run(() => {
|
||||
return Task.Run(() =>
|
||||
{
|
||||
client.Insertable(new SpitDemoModel()).SplitTable().ExecuteCommand();
|
||||
});
|
||||
}
|
||||
@ -43,4 +45,4 @@ namespace OrmTest
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using SqlSugar;
|
||||
using KdbndpTest.OracleDemo.UnitTest;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using KdbndpTest.OracleDemo;
|
||||
using KdbndpTest.SqlServerDemo;
|
||||
using System;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
@ -6,24 +8,12 @@ namespace OrmTest
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//Demo
|
||||
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();
|
||||
|
||||
//Oracle模式DEMO
|
||||
OracleDemo.Init();
|
||||
|
||||
//SqlServer模式DEMO
|
||||
SqlServer.Init();
|
||||
|
||||
//Unit test
|
||||
//NewUnitTest.Init();
|
||||
|
51
Src/Asp.NetCore2/KdbndpTest/SqlServerDemo/SqlServer.cs
Normal file
51
Src/Asp.NetCore2/KdbndpTest/SqlServerDemo/SqlServer.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user