mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-05 17:37:58 +08:00
Update xugu db
This commit is contained in:
parent
9c8ce40842
commit
b5b64681ce
@ -2,7 +2,7 @@
|
|||||||
<package >
|
<package >
|
||||||
<metadata>
|
<metadata>
|
||||||
<id>SqlSugar.XuguCoreNew</id>
|
<id>SqlSugar.XuguCoreNew</id>
|
||||||
<version>5.1.4.172</version>
|
<version>5.1.4.173</version>
|
||||||
<authors>sunkaixuan</authors>
|
<authors>sunkaixuan</authors>
|
||||||
<owners>果糖大数据</owners>
|
<owners>果糖大数据</owners>
|
||||||
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
<licenseUrl>http://www.apache.org/licenses/LICENSE-2.0.html</licenseUrl>
|
||||||
|
@ -9,6 +9,11 @@ namespace SqlSugar.Xugu
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static class UtilExtensions
|
public static class UtilExtensions
|
||||||
{
|
{
|
||||||
|
public static bool IsContainsStartWithIn(this string thisValue, params string[] inValues)
|
||||||
|
{
|
||||||
|
return inValues.Any(it => thisValue.StartsWith(it));
|
||||||
|
}
|
||||||
|
|
||||||
public static bool EqualCase(this string thisValue, string equalValue)
|
public static bool EqualCase(this string thisValue, string equalValue)
|
||||||
{
|
{
|
||||||
if (thisValue != null && equalValue != null)return thisValue.ToLower() == equalValue.ToLower();
|
if (thisValue != null && equalValue != null)return thisValue.ToLower() == equalValue.ToLower();
|
||||||
|
@ -156,6 +156,7 @@ namespace SqlSugar.Xugu
|
|||||||
public override DbCommand GetCommand(string sql, SugarParameter[] parameters)
|
public override DbCommand GetCommand(string sql, SugarParameter[] parameters)
|
||||||
{
|
{
|
||||||
CheckSqlNull(sql);
|
CheckSqlNull(sql);
|
||||||
|
sql = ReplaceKeyWordParameterName(sql, parameters);
|
||||||
var helper = new XuguInsertBuilder();
|
var helper = new XuguInsertBuilder();
|
||||||
helper.Context = this.Context;
|
helper.Context = this.Context;
|
||||||
//if (parameters != null)
|
//if (parameters != null)
|
||||||
@ -279,5 +280,51 @@ namespace SqlSugar.Xugu
|
|||||||
else if (parameter.DbType == System.Data.DbType.UInt64) return System.Data.DbType.Int64;
|
else if (parameter.DbType == System.Data.DbType.UInt64) return System.Data.DbType.Int64;
|
||||||
else return parameter.DbType;
|
else return parameter.DbType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string[] KeyWord = new string[] { ":number","@number","@month", ":month", ":day", "@day", "@group", ":group", ":index", "@index", "@order", ":order", "@user", "@level", ":user", ":level", ":type", "@type", ":year", "@year", "@date", ":date" };
|
||||||
|
private static string ReplaceKeyWordParameterName(string sql, SugarParameter[] parameters)
|
||||||
|
{
|
||||||
|
sql = ReplaceKeyWordWithAd(sql, parameters);
|
||||||
|
if (parameters.HasValue())
|
||||||
|
{
|
||||||
|
foreach (var Parameter in parameters.OrderByDescending(x => x.ParameterName?.Length))
|
||||||
|
{
|
||||||
|
if (Parameter.ParameterName != null && Parameter.ParameterName.ToLower().IsContainsStartWithIn(KeyWord))
|
||||||
|
{
|
||||||
|
if (parameters.Count(it => it.ParameterName.StartsWith(Parameter.ParameterName)) == 1)
|
||||||
|
{
|
||||||
|
var newName = Parameter.ParameterName + "_01";
|
||||||
|
newName = newName.Insert(1, "KW");
|
||||||
|
sql = Regex.Replace(sql, Parameter.ParameterName, newName, RegexOptions.IgnoreCase);
|
||||||
|
Parameter.ParameterName = newName;
|
||||||
|
}
|
||||||
|
else if (Parameter.ParameterName.ToLower().IsContainsIn(KeyWord))
|
||||||
|
{
|
||||||
|
Check.ExceptionEasy($" {Parameter.ParameterName} is key word", $"{Parameter.ParameterName}是关键词");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string ReplaceKeyWordWithAd(string sql, SugarParameter[] parameters)
|
||||||
|
{
|
||||||
|
if (parameters != null && sql != null && sql.Contains("@"))
|
||||||
|
{
|
||||||
|
foreach (var item in parameters.OrderByDescending(it => it.ParameterName.Length))
|
||||||
|
{
|
||||||
|
if (item.ParameterName.StartsWith("@"))
|
||||||
|
{
|
||||||
|
item.ParameterName = ":" + item.ParameterName.TrimStart('@');
|
||||||
|
}
|
||||||
|
sql = Regex.Replace(sql, "@" + item.ParameterName.TrimStart(':'), item.ParameterName, RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user