SqlSugar/Src/Asp.NetCore2/SqlSeverTest/Demo/Demo8_Saveable.cs

44 lines
1.2 KiB
C#
Raw Normal View History

2019-06-04 21:03:27 +08:00
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OrmTest
{
public class Demo8_Saveable
{
public static void Init()
{
Console.WriteLine("");
Console.WriteLine("#### Saveable Start ####");
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
{
DbType = DbType.SqlServer,
ConnectionString = Config.ConnectionString,
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true,
AopEvents = new AopEvents
{
OnLogExecuting = (sql, p) =>
{
Console.WriteLine(sql);
Console.WriteLine(string.Join(",", p?.Select(it => it.ParameterName + ":" + it.Value)));
}
}
});
//insert or update
2023-05-05 09:00:50 +08:00
db.Storageable<Order>(new Order() { Id=1, Name="jack" }).ExecuteCommand();
2019-06-04 21:03:27 +08:00
2023-05-05 09:00:50 +08:00
2019-06-04 21:03:27 +08:00
Console.WriteLine("");
Console.WriteLine("#### Saveable End ####");
}
}
}