From ee05df69f6ceab8d41fd778632589a11107d3c5d Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Sun, 2 Jun 2019 19:28:09 +0800 Subject: [PATCH] Update demo --- .../SqlServerTest/Demo/Demo9_EntityMain.cs | 7 ++++- .../SqlServerTest/Demo/DemoA_DbMain.cs | 6 ++++ Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs | 31 +++++++++++++------ 3 files changed, 34 insertions(+), 10 deletions(-) diff --git a/Src/Asp.Net/SqlServerTest/Demo/Demo9_EntityMain.cs b/Src/Asp.Net/SqlServerTest/Demo/Demo9_EntityMain.cs index 11ec8f3a1..338898d9b 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/Demo9_EntityMain.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/Demo9_EntityMain.cs @@ -29,7 +29,12 @@ namespace OrmTest } } }); - + var entityInfo = db.EntityMaintenance.GetEntityInfo(); + foreach (var column in entityInfo.Columns) + { + Console.WriteLine(column.DbColumnName); + } + //more https://github.com/sunkaixuan/SqlSugar/wiki/9.EntityMain Console.WriteLine("#### EntityMain End ####"); } } diff --git a/Src/Asp.Net/SqlServerTest/Demo/DemoA_DbMain.cs b/Src/Asp.Net/SqlServerTest/Demo/DemoA_DbMain.cs index 1862bf910..206cd6507 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/DemoA_DbMain.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/DemoA_DbMain.cs @@ -30,6 +30,12 @@ namespace OrmTest } }); + var tables = db.DbMaintenance.GetTableInfoList(); + foreach (var table in tables) + { + Console.WriteLine(table.Description); + } + //more https://github.com/sunkaixuan/SqlSugar/wiki/a.DbMain Console.WriteLine("#### DbMain End ####"); } } diff --git a/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs b/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs index 6b4a017c3..4b22d941e 100644 --- a/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs +++ b/Src/Asp.Net/SqlServerTest/Demo/DemoB_Aop.cs @@ -19,16 +19,29 @@ namespace OrmTest 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))); - } - } + IsAutoCloseConnection = true }); + db.Aop.OnLogExecuted = (sql, pars) => //SQL executed event + { + Console.WriteLine("OnLogExecuted"+sql); + }; + db.Aop.OnLogExecuting = (sql, pars) => //SQL executing event (pre-execution) + { + Console.WriteLine("OnLogExecuting" + sql); + }; + db.Aop.OnError = (exp) =>//SQL execution error event + { + //exp.sql + }; + db.Aop.OnExecutingChangeSql = (sql, pars) => //SQL executing event (pre-execution,SQL script can be modified) + { + return new KeyValuePair(sql, pars); + }; + + + + db.Queryable().ToList(); + db.Queryable().ToList(); Console.WriteLine("#### Aop End ####"); }