mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-23 22:11:36 +08:00
Update Demo
This commit is contained in:
parent
471b687e3a
commit
175b60c6e0
@ -8,8 +8,8 @@ namespace OrmTest
|
||||
{
|
||||
public class Config
|
||||
{
|
||||
public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=root";
|
||||
public static string ConnectionString2 = "server=localhost;Database=SQLSUGAR4XTEST;Uid=root;Pwd=root";
|
||||
public static string ConnectionString3 = "server=localhost;Database=sqlsugar4xtest;Uid=root;Pwd=root";
|
||||
public static string ConnectionString = "server=localhost;Database=SqlSugar4xTest;Uid=root;Pwd=haosql";
|
||||
public static string ConnectionString2 = "server=localhost;Database=SQLSUGAR4XTEST;Uid=root;Pwd=haosql";
|
||||
public static string ConnectionString3 = "server=localhost;Database=sqlsugar4xtest;Uid=root;Pwd=haosql";
|
||||
}
|
||||
}
|
||||
|
@ -11,8 +11,7 @@ namespace OrmTest.Demo
|
||||
public static SqlSugarClient GetInstance()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.MySql, IsAutoCloseConnection = true });
|
||||
db.Ado.IsEnableLogEvent = true;
|
||||
db.Ado.LogEventStarting = (sql, pars) =>
|
||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it=>it.ParameterName,it=>it.Value)));
|
||||
Console.WriteLine();
|
||||
|
@ -72,8 +72,7 @@ namespace OrmTest.UnitTest
|
||||
public SqlSugarClient GetInstance()
|
||||
{
|
||||
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig() { ConnectionString = Config.ConnectionString, DbType = DbType.MySql });
|
||||
db.Ado.IsEnableLogEvent = true;
|
||||
db.Ado.LogEventStarting = (sql, pars) =>
|
||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + " " + pars);
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ namespace OrmTest.UnitTest
|
||||
using (var db = GetInstance())
|
||||
{
|
||||
//db.Database.IsEnableLogEvent = true;
|
||||
db.Ado.LogEventStarting = (sql, pars) =>
|
||||
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + " " + pars);
|
||||
};
|
||||
|
@ -13,11 +13,11 @@ namespace OrmTest
|
||||
|
||||
public static void Init()
|
||||
{
|
||||
SqlSugarClient();
|
||||
DbContext();//使用DbContext美化代码
|
||||
SingletonPattern();//单例
|
||||
DistributedTransactionExample();//分布式事务
|
||||
CustomAttribute();//自定义特性
|
||||
SqlSugarClient();//Create db
|
||||
DbContext();//Optimizing SqlSugarClient usage
|
||||
SingletonPattern();//Singleten Pattern
|
||||
DistributedTransactionExample();
|
||||
CustomAttribute();
|
||||
}
|
||||
|
||||
private static void SqlSugarClient()
|
||||
|
Loading…
Reference in New Issue
Block a user