mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Synchronization code
This commit is contained in:
parent
9695626416
commit
e517e3b4de
@ -678,11 +678,7 @@ namespace SqlSugar
|
||||
var whereSql = Regex.Replace(sql, ".* WHERE ", "", RegexOptions.Singleline);
|
||||
if (IsExists(sql))
|
||||
{
|
||||
whereSql = Regex.Match(sql, @"\(EXISTS.+").Value;
|
||||
if (sql.Contains("((EXISTS"))
|
||||
{
|
||||
whereSql = $"({whereSql}";
|
||||
}
|
||||
whereSql = UtilMethods.RemoveBeforeFirstWhere(sql);
|
||||
}
|
||||
dt = this.Context.Queryable<T>().Filter(null, true).Where(whereSql).AddParameters(parameters).ToDataTable();
|
||||
}
|
||||
@ -724,7 +720,7 @@ namespace SqlSugar
|
||||
|
||||
private static bool IsExists(string sql)
|
||||
{
|
||||
return sql.Contains("WHERE (EXISTS") || sql.Contains("((EXISTS (");
|
||||
return UtilMethods.CountSubstringOccurrences(sql,"WHERE")>1;
|
||||
}
|
||||
|
||||
private void ThrowUpdateByExpression()
|
||||
|
@ -18,6 +18,23 @@ namespace SqlSugar
|
||||
{
|
||||
public class UtilMethods
|
||||
{
|
||||
public static int CountSubstringOccurrences(string mainString, string searchString)
|
||||
{
|
||||
string[] substrings = mainString.Split(new string[] { searchString }, StringSplitOptions.None);
|
||||
return substrings.Length - 1;
|
||||
}
|
||||
public static string RemoveBeforeFirstWhere(string query)
|
||||
{
|
||||
int whereIndex = query.IndexOf("WHERE", StringComparison.OrdinalIgnoreCase);
|
||||
if (whereIndex >= 0)
|
||||
{
|
||||
return query.Substring(whereIndex + "WHERE".Length);
|
||||
}
|
||||
else
|
||||
{
|
||||
return query;
|
||||
}
|
||||
}
|
||||
public static List<object> ConvertToListOfObjects(object inValues)
|
||||
{
|
||||
// 创建一个新的List<object>并逐个将元素转换并添加到其中
|
||||
|
Loading…
Reference in New Issue
Block a user