mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-20 09:28:53 +08:00
Synchronous code
This commit is contained in:
parent
8af0678121
commit
5367105492
@ -741,6 +741,15 @@ namespace SqlSugar
|
||||
{
|
||||
List<DiffLogTableInfo> result = new List<DiffLogTableInfo>();
|
||||
var whereSql = Regex.Replace(sql, ".* WHERE ", "", RegexOptions.Singleline);
|
||||
if (IsExists(sql))
|
||||
{
|
||||
// 取第一个 WHERE 后面的部分
|
||||
var match = Regex.Match(sql, @"\bWHERE\b\s*(.*)", RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
||||
if (match.Success)
|
||||
{
|
||||
whereSql = match.Groups[1].Value;
|
||||
}
|
||||
}
|
||||
var dt = this.Context.Queryable<T>().AS(this.DeleteBuilder.AsName).Filter(null, true).Where(whereSql).AddParameters(parameters).ToDataTable();
|
||||
if (dt.Rows != null && dt.Rows.Count > 0)
|
||||
{
|
||||
@ -800,5 +809,10 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsExists(string sql)
|
||||
{
|
||||
return UtilMethods.CountSubstringOccurrences(sql, "WHERE") > 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +171,12 @@ namespace SqlSugar
|
||||
var isComparisonOperator = ExpressionTool.IsComparisonOperator(expression);
|
||||
base.ExactExpression = expression;
|
||||
var leftExpression = ExpressionTool.RemoveConvert(expression.Left);
|
||||
var rightExpression =ExpressionTool.RemoveConvert(expression.Right);
|
||||
var rightExpression =ExpressionTool.RemoveConvert(expression.Right);
|
||||
if (leftExpression.Type == typeof(char))
|
||||
{
|
||||
leftExpression = expression.Left;
|
||||
rightExpression = expression.Right;
|
||||
}
|
||||
if (operatorValue.IsIn("AND","OR")&&leftExpression is BinaryExpression exp)
|
||||
{
|
||||
if (exp?.Left is BinaryExpression expChild)
|
||||
|
||||
@ -8,6 +8,7 @@ using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@ -493,7 +494,16 @@ namespace SqlSugar
|
||||
else if (IsJsonList(readerValues, item))
|
||||
{
|
||||
var json = readerValues.First(y => y.Key.EqualCase(item.Name)).Value.ToString();
|
||||
result.Add(name, DeserializeObject<List<Dictionary<string, object>>>(json));
|
||||
if (IsMongoDb())
|
||||
{
|
||||
var q=InstanceFactory.GetInsertBuilder(this.Context.CurrentConnectionConfig);
|
||||
var qv =q.DeserializeObjectFunc(json, item.PropertyType);
|
||||
result.Add(name, qv);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.Add(name, DeserializeObject<List<Dictionary<string, object>>>(json));
|
||||
}
|
||||
}
|
||||
else if (IsBytes(readerValues, item))
|
||||
{
|
||||
@ -667,8 +677,16 @@ namespace SqlSugar
|
||||
return isArray || isListItem;
|
||||
}
|
||||
|
||||
private static bool IsJsonList(Dictionary<string, object> readerValues, PropertyInfo item)
|
||||
private bool IsJsonList(Dictionary<string, object> readerValues, PropertyInfo item)
|
||||
{
|
||||
if (IsMongoDb())
|
||||
{
|
||||
return item.PropertyType.FullName.IsCollectionsList() &&
|
||||
readerValues.Any(y => y.Key.EqualCase(item.Name)) &&
|
||||
readerValues.First(y => y.Key.EqualCase(item.Name)).Value != null &&
|
||||
readerValues.First(y => y.Key.EqualCase(item.Name)).Value.GetType().FullName == "MongoDB.Bson.BsonArray" &&
|
||||
Regex.IsMatch(readerValues.First(y => y.Key.EqualCase(item.Name)).Value.ToString(), @"^\[{.+\}]$");
|
||||
}
|
||||
return item.PropertyType.FullName.IsCollectionsList() &&
|
||||
readerValues.Any(y => y.Key.EqualCase(item.Name)) &&
|
||||
readerValues.First(y => y.Key.EqualCase(item.Name)).Value != null &&
|
||||
@ -676,6 +694,11 @@ namespace SqlSugar
|
||||
Regex.IsMatch(readerValues.First(y => y.Key.EqualCase(item.Name)).Value.ToString(), @"^\[{.+\}]$");
|
||||
}
|
||||
|
||||
private bool IsMongoDb()
|
||||
{
|
||||
return this.Context?.CurrentConnectionConfig?.DbType == DbType.MongoDb;
|
||||
}
|
||||
|
||||
private Dictionary<string, object> DataReaderToDynamicList_Part<T>(Dictionary<string, object> readerValues, PropertyInfo item, List<T> reval, Dictionary<string, string> mappingKeys = null,List<string> ignoreColumns=null)
|
||||
{
|
||||
Dictionary<string, object> result = new Dictionary<string, object>();
|
||||
@ -790,6 +813,10 @@ namespace SqlSugar
|
||||
{
|
||||
addItem = addItem.ObjToInt();
|
||||
}
|
||||
else if (underType == UtilConstants.LongType && addItem != null)
|
||||
{
|
||||
addItem = addItem.ObjToLong();
|
||||
}
|
||||
else if (addItem!=null&&underType?.FullName == "System.DateOnly")
|
||||
{
|
||||
addItem = Convert.ToDateTime(addItem).ToString("yyyy-MM-dd");
|
||||
|
||||
Loading…
Reference in New Issue
Block a user