mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 10:10:16 +08:00
Update exp to sql
This commit is contained in:
parent
ea02cfed8e
commit
c83511f123
@ -157,10 +157,10 @@ namespace SqlSugar
|
||||
{
|
||||
Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsTranscoding", "SetColumns方式更新不支持IsTranscoding,你可以使用db.Updateable(实体)的方式更新"));
|
||||
}
|
||||
if (checkIsJson && this.EntityInfo.Columns.Any(it => it.IsJson))
|
||||
{
|
||||
Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsJson", "SetColumns方式更新不支持IsJson,你可以使用db.Updateable(实体)的方式更新"));
|
||||
}
|
||||
//if (checkIsJson && this.EntityInfo.Columns.Any(it => it.IsJson))
|
||||
//{
|
||||
// Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsJson", "SetColumns方式更新不支持IsJson,你可以使用db.Updateable(实体)的方式更新"));
|
||||
//}
|
||||
//if (this.EntityInfo.Columns.Any(it => it.IsArray))
|
||||
//{
|
||||
// Check.Exception(true, ErrorMessage.GetThrowMessage("UpdateColumns no support IsArray", "SetColumns方式更新不支持IsArray,你可以使用db.Updateable(实体)的方式更新"));
|
||||
|
@ -141,6 +141,10 @@ namespace SqlSugar
|
||||
}
|
||||
this.Context.Parameters.Add(p);
|
||||
}
|
||||
else if (parameter?.BaseParameter?.CommonTempData.ObjToString() == "IsJon=true")
|
||||
{
|
||||
this.Context.Parameters.Add(new SugarParameter(appendValue, new SerializeService().SerializeObject(value)) { IsJson=true});
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Context.Parameters.Add(new SugarParameter(appendValue, value));
|
||||
|
@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
@ -27,9 +28,9 @@ namespace SqlSugar
|
||||
private void Other(ExpressionParameter parameter)
|
||||
{
|
||||
var expression = this.Expression as BinaryExpression;
|
||||
if (expression.NodeType == ExpressionType.ArrayIndex)
|
||||
if (expression.NodeType == ExpressionType.ArrayIndex)
|
||||
{
|
||||
var parameterName=AppendParameter(ExpressionTool.DynamicInvoke(expression));
|
||||
var parameterName = AppendParameter(ExpressionTool.DynamicInvoke(expression));
|
||||
base.Context.Result.Append($" {BaseParameter.BaseParameter.OperatorValue} {parameterName} ");
|
||||
return;
|
||||
}
|
||||
@ -43,12 +44,32 @@ namespace SqlSugar
|
||||
{
|
||||
JoinString(parameter, expression);
|
||||
}
|
||||
else if (IsUpdateJson(parameter,expression, operatorValue))
|
||||
{
|
||||
parameter.CommonTempData = "IsJon=true";
|
||||
DefaultBinary(parameter, expression, operatorValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultBinary(parameter, expression, operatorValue);
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsUpdateJson(ExpressionParameter parameter,BinaryExpression expression, string operatorValue)
|
||||
{
|
||||
var isOk= parameter.Context.ResolveType==ResolveExpressType.WhereSingle&&operatorValue == "=" && (expression.Left is MemberExpression) && expression.Left.Type.IsClass();
|
||||
if (isOk&&this.Context.SugarContext != null)
|
||||
{
|
||||
var entity = this.Context.SugarContext.Context.EntityMaintenance.GetEntityInfo(expression.Left.Type);
|
||||
var jsonColumn=entity.Columns.FirstOrDefault(it => it.IsJson && it.PropertyName == ExpressionTool.GetMemberName(expression.Left)) ;
|
||||
if (jsonColumn != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void JoinString(ExpressionParameter parameter, BinaryExpression expression)
|
||||
{
|
||||
var leftString = GetNewExpressionValue(expression.Left);
|
||||
|
Loading…
Reference in New Issue
Block a user