- 增加 ISelect.ToDataTable 系列方法;

- 增加 无参数化命令执行,便于调试;
This commit is contained in:
28810
2019-03-13 18:24:54 +08:00
parent aa2040a629
commit 1fa6c9bfc4
50 changed files with 676 additions and 331 deletions

View File

@@ -81,7 +81,9 @@ namespace FreeSql.Internal.CommonProvider {
++colidx;
}
sb.Append(") VALUES");
_params = new DbParameter[colidx * _source.Count];
//_params = new DbParameter[colidx * _source.Count];
_params = new DbParameter[0];
//_params = new DbParameter[colidx * 5]; //批量添加第5行起不使用参数化
var didx = 0;
foreach (var d in _source) {
if (didx > 0) sb.Append(", ");
@@ -90,14 +92,18 @@ namespace FreeSql.Internal.CommonProvider {
foreach (var col in _table.Columns.Values)
if (col.Attribute.IsIdentity == false && _ignore.ContainsKey(col.Attribute.Name) == false) {
if (colidx2 > 0) sb.Append(", ");
sb.Append(_commonUtils.QuoteWriteParamter(col.CsType, $"{_commonUtils.QuoteParamterName(col.CsName)}{didx}"));
object val = null;
if (_table.Properties.TryGetValue(col.CsName, out var tryp)) {
val = tryp.GetValue(d);
if (col.Attribute.IsPrimary && (col.CsType == typeof(Guid) || col.CsType == typeof(Guid?))
&& (val == null || (Guid)val == Guid.Empty)) tryp.SetValue(d, val = FreeUtil.NewMongodbId());
}
_params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}{didx}", col.CsType, val);
//if (didx >= 5)
sb.Append(_commonUtils.GetNoneParamaterSqlValue(col.CsType, val));
//else {
// sb.Append(_commonUtils.QuoteWriteParamter(col.CsType, $"{_commonUtils.QuoteParamterName(col.CsName)}{didx}"));
// _params[didx * colidx + colidx2] = _commonUtils.AppendParamter(null, $"{col.CsName}{didx}", col.CsType, val);
//}
++colidx2;
}
sb.Append(")");