mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-10-25 02:09:12 +08:00
Update HANA
This commit is contained in:
@@ -60,6 +60,7 @@ namespace SqlSugar.HANAConnector
|
||||
}
|
||||
public override DbCommand GetCommand(string sql, SugarParameter[] parameters)
|
||||
{
|
||||
sql = ReplaceKeyWordParameterName(sql, parameters);
|
||||
HanaCommand sqlCommand = new HanaCommand(sql, (HanaConnection)this.Connection);
|
||||
sqlCommand.CommandType = this.CommandType;
|
||||
sqlCommand.CommandTimeout = this.CommandTimeOut;
|
||||
@@ -139,6 +140,42 @@ namespace SqlSugar.HANAConnector
|
||||
return false;
|
||||
}
|
||||
|
||||
private static string[] KeyWord = new string[] { };
|
||||
private static string ReplaceKeyWordParameterName(string sql, SugarParameter[] parameters)
|
||||
{
|
||||
sql = ReplaceKeyWordWithAd(sql, parameters);
|
||||
if (parameters.HasValue() && parameters.Count(it => it.ParameterName.ToLower().IsIn(KeyWord)) > 0)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (var Parameter in parameters.OrderByDescending(it => it.ParameterName.Length))
|
||||
{
|
||||
if (Parameter.ParameterName != null && Parameter.ParameterName.ToLower().IsContainsIn(KeyWord))
|
||||
{
|
||||
var newName = ":p" + i + 100;
|
||||
sql =System.Text.RegularExpressions.Regex.Replace(sql, Parameter.ParameterName, newName, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
Parameter.ParameterName = newName;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 = System.Text.RegularExpressions.Regex.Replace(sql, "@" + item.ParameterName.TrimStart(':'), item.ParameterName, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
||||
}
|
||||
}
|
||||
|
||||
return sql;
|
||||
}
|
||||
|
||||
#region async
|
||||
public async Task CloseAsync()
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace SqlSugar.HANAConnector
|
||||
{
|
||||
public class HANABuilder : SqlBuilderProvider
|
||||
{
|
||||
public override string SqlTranslationLeft { get { return "`"; } }
|
||||
public override string SqlTranslationRight { get { return "`"; } }
|
||||
public override string SqlTranslationLeft { get { return "\""; } }
|
||||
public override string SqlTranslationRight { get { return "\""; } }
|
||||
public override string SqlDateNow
|
||||
{
|
||||
get
|
||||
|
||||
@@ -12,8 +12,8 @@ namespace SqlSugar.HANAConnector
|
||||
{
|
||||
base.DbMehtods = new HANAMethod();
|
||||
}
|
||||
public override string SqlTranslationLeft { get { return "`"; } }
|
||||
public override string SqlTranslationRight { get { return "`"; } }
|
||||
public override string SqlTranslationLeft { get { return "\""; } }
|
||||
public override string SqlTranslationRight { get { return "\""; } }
|
||||
}
|
||||
public class HANAMethod : DefaultDbMethod, IDbMethods
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user