From 53409f5b3a6497253e4ec70d4a017b2c9275104e Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Tue, 19 Sep 2017 02:41:23 +0800 Subject: [PATCH] Update Demo --- Src/Asp.Net/MySqlTest/Demos/1_Query.cs | 4 ++-- Src/Asp.Net/MySqlTest/Demos/DemoBase.cs | 2 +- Src/Asp.Net/SqlServerTest/Demos/DemoBase.cs | 2 +- Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoAccessory.cs | 3 +++ Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs | 4 ++-- Src/Asp.Net/SqliteTest/Demos/DemoBase.cs | 2 +- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Src/Asp.Net/MySqlTest/Demos/1_Query.cs b/Src/Asp.Net/MySqlTest/Demos/1_Query.cs index f93841062..e63430bf5 100644 --- a/Src/Asp.Net/MySqlTest/Demos/1_Query.cs +++ b/Src/Asp.Net/MySqlTest/Demos/1_Query.cs @@ -188,8 +188,8 @@ namespace OrmTest.Demo { var db = GetInstance(); db.Ado.BeginTran(); - var t1 = db.Ado.SqlQuery("select 'a'"); - var t2 = db.Ado.GetInt("select 1"); + var t1 = db.Ado.SqlQuery("select 'a'",new { id = 1 }); + var t2 = db.Ado.GetInt("select 1",new Dictionary() { { "id",1} }); var t3 = db.Ado.GetDataTable("select 1 as id"); db.Ado.CommitTran(); //more diff --git a/Src/Asp.Net/MySqlTest/Demos/DemoBase.cs b/Src/Asp.Net/MySqlTest/Demos/DemoBase.cs index e4864260b..0b630809c 100644 --- a/Src/Asp.Net/MySqlTest/Demos/DemoBase.cs +++ b/Src/Asp.Net/MySqlTest/Demos/DemoBase.cs @@ -14,7 +14,7 @@ namespace OrmTest.Demo db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { - Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars)); + Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it=>it.ParameterName,it=>it.Value))); Console.WriteLine(); }; return db; diff --git a/Src/Asp.Net/SqlServerTest/Demos/DemoBase.cs b/Src/Asp.Net/SqlServerTest/Demos/DemoBase.cs index fcdb94e8d..46e139686 100644 --- a/Src/Asp.Net/SqlServerTest/Demos/DemoBase.cs +++ b/Src/Asp.Net/SqlServerTest/Demos/DemoBase.cs @@ -14,7 +14,7 @@ namespace OrmTest.Demo db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { - Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars)); + Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); Console.WriteLine(); }; return db; diff --git a/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoAccessory.cs b/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoAccessory.cs index 1ae0c86bb..848e9d4a3 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoAccessory.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoAccessory.cs @@ -26,7 +26,10 @@ namespace SqlSugar if (isDictionary) DictionaryToParameters(parameters, sqlParameterKeyWord, result, entityType); else + { + Check.Exception(!entityType.IsAnonymousType(), "The parameter format is wrong. \nUse new{{xx=xx, xx2=xx2}} or \nDictionary or \nSugarParameter [] "); ProperyToParameter(parameters, propertyInfo, sqlParameterKeyWord, result, entityType); + } } return result.ToArray(); } diff --git a/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs b/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs index 82b8d9b54..c58b2c4be 100644 --- a/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs +++ b/Src/Asp.Net/SqlSugar/Abstract/AdoProvider/AdoProvider.cs @@ -599,7 +599,7 @@ namespace SqlSugar { if (parameters == null || parameters.Length == 0) { - action(sql, null); + action(sql, new SugarParameter[] { }); } else { @@ -627,7 +627,7 @@ namespace SqlSugar { if (parameters == null || parameters.Length == 0) { - action(sql, null); + action(sql, new SugarParameter[] { }); } else { diff --git a/Src/Asp.Net/SqliteTest/Demos/DemoBase.cs b/Src/Asp.Net/SqliteTest/Demos/DemoBase.cs index 8846b1826..ad918de2e 100644 --- a/Src/Asp.Net/SqliteTest/Demos/DemoBase.cs +++ b/Src/Asp.Net/SqliteTest/Demos/DemoBase.cs @@ -14,7 +14,7 @@ namespace OrmTest.Demo db.Ado.IsEnableLogEvent = true; db.Ado.LogEventStarting = (sql, pars) => { - Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars)); + Console.WriteLine(sql + "\r\n" + db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value))); Console.WriteLine(); }; return db;