Update exp to sql

This commit is contained in:
sunkaixuan
2022-07-02 21:09:36 +08:00
parent 96367b210e
commit d8d2be1274
3 changed files with 34 additions and 8 deletions

View File

@@ -291,6 +291,10 @@ namespace SqlSugar
{ {
column.DataType = "json"; column.DataType = "json";
} }
else if (column.Length > 0)
{
column.DataType = "varchar";
}
else else
{ {
column.DataType = "varchar(4000)"; column.DataType = "varchar(4000)";

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SqlSugar namespace SqlSugar
@@ -155,11 +156,21 @@ namespace SqlSugar
if (sql == null) return sql; if (sql == null) return sql;
joinInfos.Last().ThisEntityInfo.Columns.ForEach(it => joinInfos.Last().ThisEntityInfo.Columns.ForEach(it =>
{ {
this.whereSql = this.whereSql.Replace(sqlBuilder.GetTranslationColumnName(it.DbColumnName), if (it.DbColumnName != null)
lastShortName+"." + sqlBuilder.GetTranslationColumnName(it.DbColumnName)); {
if (this.whereSql.Contains("." + sqlBuilder.GetTranslationColumnName(it.DbColumnName)))
{
this.whereSql =Regex.Replace(this.whereSql,@"\w+\."+sqlBuilder.GetTranslationColumnName(it.DbColumnName),
lastShortName + "." + sqlBuilder.GetTranslationColumnName(it.DbColumnName));
}
else
{
this.whereSql = this.whereSql.Replace(sqlBuilder.GetTranslationColumnName(it.DbColumnName),
lastShortName + "." + sqlBuilder.GetTranslationColumnName(it.DbColumnName));
}
}
}); });
return sql; return this.whereSql;
} }
private string GetWhereSql(MethodCallExpression memberExp) private string GetWhereSql(MethodCallExpression memberExp)

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace SqlSugar namespace SqlSugar
@@ -155,11 +156,21 @@ namespace SqlSugar
if (sql == null) return sql; if (sql == null) return sql;
joinInfos.Last().ThisEntityInfo.Columns.ForEach(it => joinInfos.Last().ThisEntityInfo.Columns.ForEach(it =>
{ {
this.whereSql = this.whereSql.Replace(sqlBuilder.GetTranslationColumnName(it.DbColumnName), if (it.DbColumnName != null)
lastShortName+"." + sqlBuilder.GetTranslationColumnName(it.DbColumnName)); {
if (this.whereSql.Contains("." + sqlBuilder.GetTranslationColumnName(it.DbColumnName)))
{
this.whereSql =Regex.Replace(this.whereSql,@"\w+\."+sqlBuilder.GetTranslationColumnName(it.DbColumnName),
lastShortName + "." + sqlBuilder.GetTranslationColumnName(it.DbColumnName));
}
else
{
this.whereSql = this.whereSql.Replace(sqlBuilder.GetTranslationColumnName(it.DbColumnName),
lastShortName + "." + sqlBuilder.GetTranslationColumnName(it.DbColumnName));
}
}
}); });
return sql; return this.whereSql;
} }
private string GetWhereSql(MethodCallExpression memberExp) private string GetWhereSql(MethodCallExpression memberExp)