mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-08-01 19:15:10 +08:00
Update exp to sql
This commit is contained in:
parent
1c27b1ab1c
commit
6134010f97
@ -206,19 +206,28 @@ namespace SqlSugar
|
||||
else if (type.IsIn(typeof(decimal), typeof(double)))
|
||||
{
|
||||
Expression<Func<SingleColumnEntity<object>, object>> exp = it => Convert.ToDecimal(it.ColumnName);
|
||||
var result = queryBuilder.GetExpressionValue(exp, ResolveExpressType.WhereSingle).GetResultString();
|
||||
result = Regex.Replace(result, @"\[ColumnName\]", formatBuilder.FormatValue(value) + "", RegexOptions.IgnoreCase);
|
||||
result = Regex.Replace(result, @"\`ColumnName\`", formatBuilder.FormatValue(value) + "", RegexOptions.IgnoreCase);
|
||||
result = Regex.Replace(result, @"""ColumnName""", formatBuilder.FormatValue(value) + "", RegexOptions.IgnoreCase);
|
||||
var result = queryBuilder.LambdaExpressions.DbMehtods.ToDecimal(new MethodCallExpressionModel() {
|
||||
Args=new List<MethodCallExpressionArgs>() {
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName= formatBuilder.FormatValue(value)
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
else if (type.IsIn(typeof(DateTime)))
|
||||
{
|
||||
Expression<Func<SingleColumnEntity<object>, object>> exp= it => Convert.ToDateTime(it.ColumnName);
|
||||
var result= queryBuilder.GetExpressionValue(exp,ResolveExpressType.WhereSingle).GetResultString();
|
||||
result = Regex.Replace(result, @"\[ColumnName\]", formatBuilder.FormatValue(value)+"",RegexOptions.IgnoreCase);
|
||||
result = Regex.Replace(result, @"\`ColumnName\`", formatBuilder.FormatValue(value) + "", RegexOptions.IgnoreCase);
|
||||
result = Regex.Replace(result, @"""ColumnName""", formatBuilder.FormatValue(value) + "", RegexOptions.IgnoreCase);
|
||||
Expression<Func<SingleColumnEntity<object>, object>> exp = it => Convert.ToDecimal(it.ColumnName);
|
||||
var result = queryBuilder.LambdaExpressions.DbMehtods.ToDate(new MethodCallExpressionModel()
|
||||
{
|
||||
Args = new List<MethodCallExpressionArgs>() {
|
||||
new MethodCallExpressionArgs(){
|
||||
IsMember=true,
|
||||
MemberName= formatBuilder.FormatValue(value)
|
||||
}
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
else
|
||||
|
@ -174,6 +174,11 @@ namespace SqlSugar
|
||||
}
|
||||
public virtual object FormatValue(object value)
|
||||
{
|
||||
var N = "N";
|
||||
if (this.Context.CurrentConnectionConfig.DbType == DbType.Sqlite)
|
||||
{
|
||||
N = "";
|
||||
}
|
||||
if (value == null)
|
||||
{
|
||||
return "NULL";
|
||||
@ -212,7 +217,7 @@ namespace SqlSugar
|
||||
}
|
||||
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
|
||||
{
|
||||
return "N'" + value.ToString().ToSqlFilter() + "'";
|
||||
return N+"'" + value.ToString().ToSqlFilter() + "'";
|
||||
}
|
||||
else if (type == UtilConstants.DateTimeOffsetType)
|
||||
{
|
||||
@ -221,11 +226,11 @@ namespace SqlSugar
|
||||
}
|
||||
else if (type == UtilConstants.FloatType)
|
||||
{
|
||||
return "N'" +Convert.ToDouble(value).ToString() + "'";
|
||||
return N+"'" +Convert.ToDouble(value).ToString() + "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "N'" + value.ToString() + "'";
|
||||
return N+"'" + value.ToString() + "'";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user