From 7229c08d0dc9f0b512c4ef97f68d9a934ebc9504 Mon Sep 17 00:00:00 2001 From: 28810 <28810@YEXIANGQIN> Date: Fri, 27 Mar 2020 16:26:59 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BF=AE=E5=A4=8D=20=E6=9C=AC=E5=9C=B0?= =?UTF-8?q?=E5=8C=BA=E5=9F=9F=E5=8C=96=E5=90=8E=20ToSql=20=E4=BA=A7?= =?UTF-8?q?=E7=94=9F=E7=9A=84=E9=94=99=E8=AF=AF=EF=BC=8C=E6=AF=94=E5=A6=82?= =?UTF-8?q?=E6=95=B0=E5=AD=97=E5=8F=AF=E8=83=BD=E7=94=9F=E6=88=90=20SQL=20?= =?UTF-8?q?=E4=B8=BA=EF=BC=9A100,000=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FreeSql.DbContext/FreeSql.DbContext.xml | 7 + FreeSql/FreeSql.xml | 143 ++++++++++++++++++ FreeSql/Internal/CommonExpression.cs | 4 +- .../AdoProvider/AdoProviderUtils.cs | 3 +- 4 files changed, 155 insertions(+), 2 deletions(-) diff --git a/FreeSql.DbContext/FreeSql.DbContext.xml b/FreeSql.DbContext/FreeSql.DbContext.xml index 28fdb213..d8bba58b 100644 --- a/FreeSql.DbContext/FreeSql.DbContext.xml +++ b/FreeSql.DbContext/FreeSql.DbContext.xml @@ -110,6 +110,13 @@ 清空状态数据 + + + 根据 lambda 条件删除数据 + + + + 添加 diff --git a/FreeSql/FreeSql.xml b/FreeSql/FreeSql.xml index e63a0ae4..17e209b4 100644 --- a/FreeSql/FreeSql.xml +++ b/FreeSql/FreeSql.xml @@ -2285,6 +2285,137 @@ + + + 查询,若使用读写分离,查询【从库】条件cmdText.StartsWith("SELECT "),否则查询【主库】 + + + + + + + + + 查询,ExecuteReaderAsync(dr => {}, "select * from user where age > ?age", new { age = 25 }) + + + + + + + 查询 + + + + + + + 查询,ExecuteArrayAsync("select * from user where age > ?age", new { age = 25 }) + + + + + + + + 查询 + + + + + + + 查询,ExecuteDataSetAsync("select * from user where age > ?age; select 2", new { age = 25 }) + + + + + + + + 查询 + + + + + + + 查询,ExecuteDataTableAsync("select * from user where age > ?age", new { age = 25 }) + + + + + + + + 在【主库】执行 + + + + + + + + 在【主库】执行,ExecuteNonQueryAsync("delete from user where age > ?age", new { age = 25 }) + + + + + + + + 在【主库】执行 + + + + + + + + 在【主库】执行,ExecuteScalarAsync("select 1 from user where age > ?age", new { age = 25 }) + + + + + + + + 执行SQL返回对象集合,QueryAsync<User>("select * from user where age > ?age", new SqlParameter { ParameterName = "age", Value = 25 }) + + + + + + + + + + 执行SQL返回对象集合,QueryAsync<User>("select * from user where age > ?age", new { age = 25 }) + + + + + + + + + 执行SQL返回对象集合,Query<User>("select * from user where age > ?age; select * from address", new SqlParameter { ParameterName = "age", Value = 25 }) + + + + + + + + + + 执行SQL返回对象集合,Query<User>("select * from user where age > ?age; select * from address", new { age = 25 }) + + + + + + 可自定义解析表达式 @@ -2808,6 +2939,12 @@ 超时 + + + 获取资源 + + + 使用完毕后,归还资源 @@ -2878,6 +3015,12 @@ 资源对象 + + + 从对象池获取对象成功的时候触发,通过该方法统计或初始化对象 + + 资源对象 + 归还对象给对象池的时候触发 diff --git a/FreeSql/Internal/CommonExpression.cs b/FreeSql/Internal/CommonExpression.cs index 5493f699..93e78a51 100644 --- a/FreeSql/Internal/CommonExpression.cs +++ b/FreeSql/Internal/CommonExpression.cs @@ -11,6 +11,7 @@ using System.Text; using System.Text.RegularExpressions; using FreeSql.DataAnnotations; using System.Threading; +using System.Globalization; namespace FreeSql.Internal { @@ -1501,7 +1502,8 @@ namespace FreeSql.Internal mapType ?? mapColumn?.Attribute.MapType ?? obj?.GetType(), mapType == null ? obj : Utils.GetDataReaderValue(mapType, obj)); return _common.QuoteParamterName(paramName); } - return string.Concat(_ado.AddslashesProcessParam(obj, mapType, mapColumn)); + return string.Format(CultureInfo.InvariantCulture, "{0}", _ado.AddslashesProcessParam(obj, mapType, mapColumn)); + //return string.Concat(_ado.AddslashesProcessParam(obj, mapType, mapColumn)); } } } diff --git a/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderUtils.cs b/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderUtils.cs index 9edce10c..a8b1d542 100644 --- a/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderUtils.cs +++ b/FreeSql/Internal/CommonProvider/AdoProvider/AdoProviderUtils.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using System.Collections.Concurrent; +using System.Globalization; using System.Text; using System.Text.RegularExpressions; @@ -22,7 +23,7 @@ namespace FreeSql.Internal.CommonProvider .Replace(filter, $" IS {{{a}}}"); nparms[a] = AddslashesProcessParam(parms[a], null, null); } - try { string ret = string.Format(filter, nparms); return ret; } catch { return filter; } + try { string ret = string.Format(CultureInfo.InvariantCulture, filter, nparms); return ret; } catch { return filter; } } static ConcurrentDictionary _dicAddslashesReplaceIsNull = new ConcurrentDictionary();