mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-12-21 17:05:47 +08:00
- 增加 ISelect.ToDataTable 系列方法;
- 增加 无参数化命令执行,便于调试;
This commit is contained in:
@@ -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(")");
|
||||
|
||||
Reference in New Issue
Block a user