mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 10:10:16 +08:00
Update .net core
This commit is contained in:
parent
032df6c145
commit
6852578e73
@ -129,7 +129,17 @@ namespace SqlSugar
|
|||||||
if (model is ConditionalModel)
|
if (model is ConditionalModel)
|
||||||
{
|
{
|
||||||
var item = model as ConditionalModel;
|
var item = model as ConditionalModel;
|
||||||
if (item.FieldName == $"[value=sql{UtilConstants.ReplaceKey}]")
|
if (item.CustomConditionalFunc != null)
|
||||||
|
{
|
||||||
|
var colIndex = mainIndex + beginIndex;
|
||||||
|
var colType = colIndex == 0 ? "" : "AND";
|
||||||
|
var custom = item.CustomConditionalFunc.GetConditionalSql(item, colIndex);
|
||||||
|
parameters.AddRange(custom.Value);
|
||||||
|
builder.AppendFormat(" "+colType + " "+custom.Key);
|
||||||
|
mainIndex++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else if (item.FieldName == $"[value=sql{UtilConstants.ReplaceKey}]")
|
||||||
{
|
{
|
||||||
builder.Append(item.FieldValue);
|
builder.Append(item.FieldValue);
|
||||||
continue;
|
continue;
|
||||||
|
@ -25,6 +25,14 @@ namespace SqlSugar
|
|||||||
public string FieldName { get; set; }
|
public string FieldName { get; set; }
|
||||||
public string FieldValue { get; set; }
|
public string FieldValue { get; set; }
|
||||||
public string CSharpTypeName { get; set; }
|
public string CSharpTypeName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
public ICustomConditionalFunc CustomConditionalFunc { get; set; }
|
||||||
|
public string CustomP1 { get; set; }
|
||||||
|
public string CustomP2 { get; set; }
|
||||||
|
public string CustomP3 { get; set; }
|
||||||
|
public string CustomP4 { get; set; }
|
||||||
|
|
||||||
public ConditionalType ConditionalType { get; set; }
|
public ConditionalType ConditionalType { get; set; }
|
||||||
[Newtonsoft.Json.JsonIgnoreAttribute]
|
[Newtonsoft.Json.JsonIgnoreAttribute]
|
||||||
public Func<string,object> FieldValueConvertFunc { get; set; }
|
public Func<string,object> FieldValueConvertFunc { get; set; }
|
||||||
|
@ -45,10 +45,11 @@ namespace SqlSugar
|
|||||||
var exp = expression as MethodCallExpression;
|
var exp = expression as MethodCallExpression;
|
||||||
InitType(exp);
|
InitType(exp);
|
||||||
var result = "";
|
var result = "";
|
||||||
if (this.Context.JoinIndex == 0)
|
|
||||||
result = SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldSingle);
|
var oldIsSingle = this.Context.IsSingle;
|
||||||
else
|
this.Context.IsSingle = false;
|
||||||
result = SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldMultiple);
|
result = SubTools.GetMethodValue(this.Context, exp.Arguments[0], ResolveExpressType.FieldMultiple);
|
||||||
|
this.Context.IsSingle = oldIsSingle;
|
||||||
|
|
||||||
SetShortName(exp, result);
|
SetShortName(exp, result);
|
||||||
|
|
||||||
@ -69,7 +70,7 @@ namespace SqlSugar
|
|||||||
|
|
||||||
public void SetShortName(MethodCallExpression exp, string result)
|
public void SetShortName(MethodCallExpression exp, string result)
|
||||||
{
|
{
|
||||||
if (exp.Arguments[0] is LambdaExpression && result.IsContainsIn("+", "-","*","/"))
|
if (exp.Arguments[0] is LambdaExpression)
|
||||||
{
|
{
|
||||||
var parameters = (exp.Arguments[0] as LambdaExpression).Parameters;
|
var parameters = (exp.Arguments[0] as LambdaExpression).Parameters;
|
||||||
if (parameters != null && parameters.Count > 0)
|
if (parameters != null && parameters.Count > 0)
|
||||||
@ -81,7 +82,7 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
public void SetShortNameNext(MethodCallExpression exp, string result)
|
public void SetShortNameNext(MethodCallExpression exp, string result)
|
||||||
{
|
{
|
||||||
if (exp.Arguments.Count>1&&exp.Arguments[1] is LambdaExpression && result.IsContainsIn("+", "-", "*", "/"))
|
if (exp.Arguments.Count>1&&exp.Arguments[1] is LambdaExpression )
|
||||||
{
|
{
|
||||||
var parameters = (exp.Arguments[1] as LambdaExpression).Parameters;
|
var parameters = (exp.Arguments[1] as LambdaExpression).Parameters;
|
||||||
if (parameters != null && parameters.Count > 0)
|
if (parameters != null && parameters.Count > 0)
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SqlSugar
|
||||||
|
{
|
||||||
|
public interface ICustomConditionalFunc
|
||||||
|
{
|
||||||
|
KeyValuePair<string, SugarParameter[]> GetConditionalSql(ConditionalModel json,int index);
|
||||||
|
}
|
||||||
|
}
|
@ -52,7 +52,9 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
if (!value.IsNullOrEmpty())
|
if (!value.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
var oldLength=value.Length;
|
||||||
value = value.Replace("'", "''");
|
value = value.Replace("'", "''");
|
||||||
|
if (oldLength!=value.Length&& value.IndexOf(")")>0&&value.IndexOf(@"\''")>0) value=value.Replace("\\","\\\\");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -77,6 +79,17 @@ namespace SqlSugar
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
public static string ToCheckRegexW(this string value)
|
||||||
|
{
|
||||||
|
if (Regex.IsMatch(value,@"^\w+$"))
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"ToCheckRegexW {value} format error ");
|
||||||
|
}
|
||||||
|
}
|
||||||
internal static string ToLower(this string value ,bool isAutoToLower)
|
internal static string ToLower(this string value ,bool isAutoToLower)
|
||||||
{
|
{
|
||||||
if (value == null) return null;
|
if (value == null) return null;
|
||||||
|
Loading…
Reference in New Issue
Block a user