SqlSugar/Src/Asp.NetCore2/HANATest/Program.cs

49 lines
1.3 KiB
C#
Raw Normal View History

2025-03-10 15:33:39 +08:00

using SqlSugar;
2025-03-10 16:13:42 +08:00
namespace GbaseTest
2025-03-10 15:33:39 +08:00
{
2025-03-10 16:13:42 +08:00
internal class Program
{
static void Main(string[] args)
{
//这行代码扔程序启动时
InstanceFactory.CustomAssemblies = new System.Reflection.Assembly[] {
2025-03-10 16:26:10 +08:00
typeof(SqlSugar.HANAConnector.HANAProvider).Assembly };
2025-03-10 15:33:39 +08:00
2025-03-10 16:26:10 +08:00
//创建DB
2025-03-10 16:13:42 +08:00
var db = new SqlSugarClient(new ConnectionConfig()
{
2025-03-10 17:18:34 +08:00
ConnectionString = "DRIVER={HANAQAS64};SERVERNODE=172.16.10.12:32015;UID=XXX;PWD=XXX;DATABASENAME=Q00",
2025-03-10 16:13:42 +08:00
DbType = DbType.HANA,
IsAutoCloseConnection = true,
}, db =>
{
2025-03-10 15:33:39 +08:00
2025-03-10 16:13:42 +08:00
db.Aop.OnLogExecuting = (x, y) =>
{
Console.WriteLine(x);
};
2025-03-10 16:26:10 +08:00
});
2025-03-10 16:13:42 +08:00
db.Open();
db.Close();
var dt = db.Ado.GetDataTable("SELECT * from DF_MM_POINFO where id=:id ", new { id = 1 });
var list = db.Queryable<DF_MM_POINFO>().Where(IT => IT.ID > 0).ToList();
2025-03-10 16:26:10 +08:00
int count = 0;
var listPage = db.Queryable<DF_MM_POINFO>().Where(IT => IT.ID > 0).ToPageList(2, 2, ref count);
2025-03-10 16:13:42 +08:00
Console.WriteLine("Hello, World!");
}
public class DF_MM_POINFO
{
public int ID { get; set; }
}
}
}