mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-22 20:13:41 +08:00
Optimized code
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
@@ -18,6 +18,18 @@ namespace SqlSugar
|
||||
{
|
||||
public class UtilMethods
|
||||
{
|
||||
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>并逐个将元素转换并添加到其中
|
||||
|
Reference in New Issue
Block a user