- 优化 Contains 表达式解析为 where in 自动拆分,防止大于 1000 的 SQL 错误;

This commit is contained in:
28810
2019-11-20 16:06:45 +08:00
parent d42b2fc2b8
commit 9f97d67cb2
32 changed files with 201 additions and 86 deletions

View File

@ -1,6 +1,8 @@
using FreeSql.Internal.Model;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Text;
using System.Text.RegularExpressions;
namespace FreeSql.Internal.CommonProvider
@ -23,5 +25,24 @@ namespace FreeSql.Internal.CommonProvider
try { string ret = string.Format(filter, nparms); return ret; } catch { return filter; }
}
static ConcurrentDictionary<int, Regex> _dicAddslashesReplaceIsNull = new ConcurrentDictionary<int, Regex>();
protected string AddslashesIEnumerable(object param, Type mapType, ColumnInfo mapColumn)
{
var sb = new StringBuilder();
var ie = param as IEnumerable;
var idx = 0;
foreach (var z in ie)
{
sb.Append(",");
if (++idx > 500)
{
sb.Append(" \r\n \r\n"); //500元素分割, 3空格\r\n4空格
idx = 1;
}
sb.Append(AddslashesProcessParam(z, mapType, mapColumn));
}
return sb.Length == 0 ? "(NULL)" : sb.Remove(0, 1).Insert(0, "(").Append(")").ToString();
}
}
}