mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-11-08 02:14:53 +08:00
Support varchar
This commit is contained in:
@@ -326,12 +326,20 @@ namespace SqlSugar
|
||||
internal string GetN()
|
||||
{
|
||||
var N = "N";
|
||||
if (_Context.CurrentConnectionConfig.MoreSettings != null && _Context.CurrentConnectionConfig.MoreSettings.OracleDisableNvarchar)
|
||||
if (_Context.CurrentConnectionConfig.MoreSettings != null && _Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
|
||||
{
|
||||
N = "";
|
||||
}
|
||||
return N;
|
||||
}
|
||||
internal bool IsVarchar()
|
||||
{
|
||||
if (_Context.CurrentConnectionConfig.MoreSettings != null && _Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static void CheckDbDependency(ConnectionConfig config)
|
||||
{
|
||||
switch (config.DbType)
|
||||
|
||||
@@ -9,15 +9,8 @@ namespace SqlSugar
|
||||
{
|
||||
public bool IsAutoRemoveDataCache { get; set; }
|
||||
public bool IsWithNoLockQuery { get; set; }
|
||||
/// <summary>
|
||||
/// Some MYSQL databases do not support Nvarchar set true
|
||||
/// </summary>
|
||||
public bool MySqlDisableNvarchar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
///Oracle nvarchar partial operation disabled
|
||||
/// </summary>
|
||||
public bool OracleDisableNvarchar { get; set; }
|
||||
|
||||
public bool DisableNvarchar { get; set; }
|
||||
public bool PgSqlIsAutoToLower = true;
|
||||
public int DefaultCacheDurationInSeconds { get; set; }
|
||||
}
|
||||
|
||||
@@ -109,6 +109,7 @@ namespace SqlSugar
|
||||
if (parameters == null || parameters.Length == 0) return null;
|
||||
DmParameter[] result = new DmParameter[parameters.Length];
|
||||
int index = 0;
|
||||
var isVarchar = this.Context.IsVarchar();
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
||||
@@ -134,6 +135,10 @@ namespace SqlSugar
|
||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||
this.OutputParameters.Add(sqlParameter);
|
||||
}
|
||||
if (isVarchar && sqlParameter.DbType == System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.AnsiString;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -89,6 +89,7 @@ namespace SqlSugar
|
||||
if (parameters == null || parameters.Length == 0) return null;
|
||||
MySqlParameter[] result = new MySqlParameter[parameters.Length];
|
||||
int index = 0;
|
||||
var isVarchar = this.Context.IsVarchar();
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
||||
@@ -113,6 +114,10 @@ namespace SqlSugar
|
||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||
this.OutputParameters.Add(sqlParameter);
|
||||
}
|
||||
if (isVarchar && sqlParameter.DbType == System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.AnsiString;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace SqlSugar
|
||||
public override object FormatValue(object value)
|
||||
{
|
||||
var n = "N";
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.MySqlDisableNvarchar)
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
|
||||
{
|
||||
n = "";
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace SqlSugar
|
||||
public override object FormatValue(object value)
|
||||
{
|
||||
var n = "N";
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null&&this.Context.CurrentConnectionConfig.MoreSettings.MySqlDisableNvarchar)
|
||||
if (this.Context.CurrentConnectionConfig.MoreSettings != null&&this.Context.CurrentConnectionConfig.MoreSettings.DisableNvarchar)
|
||||
{
|
||||
n = "";
|
||||
}
|
||||
|
||||
@@ -115,6 +115,7 @@ namespace SqlSugar
|
||||
if (parameters == null || parameters.Length == 0) return null;
|
||||
OracleParameter[] result = new OracleParameter[parameters.Length];
|
||||
int index = 0;
|
||||
var isVarchar = this.Context.IsVarchar();
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
||||
@@ -172,7 +173,10 @@ namespace SqlSugar
|
||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||
this.OutputParameters.Add(sqlParameter);
|
||||
}
|
||||
|
||||
if (isVarchar && sqlParameter.DbType == System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.AnsiString;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -86,6 +86,7 @@ namespace SqlSugar
|
||||
if (parameters == null || parameters.Length == 0) return null;
|
||||
NpgsqlParameter[] result = new NpgsqlParameter[parameters.Length];
|
||||
int index = 0;
|
||||
var isVarchar = this.Context.IsVarchar();
|
||||
foreach (var parameter in parameters)
|
||||
{
|
||||
if (parameter.Value == null) parameter.Value = DBNull.Value;
|
||||
@@ -123,6 +124,10 @@ namespace SqlSugar
|
||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||
this.OutputParameters.Add(sqlParameter);
|
||||
}
|
||||
if (isVarchar && sqlParameter.DbType == System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.AnsiString;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -117,6 +117,7 @@ namespace SqlSugar
|
||||
/// <returns></returns>
|
||||
public SqlParameter[] GetSqlParameter(params SugarParameter[] parameters)
|
||||
{
|
||||
var isVarchar = this.Context.IsVarchar();
|
||||
if (parameters == null || parameters.Length == 0) return null;
|
||||
SqlParameter[] result = new SqlParameter[parameters.Length];
|
||||
int index = 0;
|
||||
@@ -150,6 +151,12 @@ namespace SqlSugar
|
||||
this.OutputParameters.RemoveAll(it => it.ParameterName == sqlParameter.ParameterName);
|
||||
this.OutputParameters.Add(sqlParameter);
|
||||
}
|
||||
|
||||
if (isVarchar&&sqlParameter.DbType== System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType =System.Data.DbType.AnsiString;
|
||||
}
|
||||
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -82,6 +82,7 @@ namespace SqlSugar
|
||||
/// <returns></returns>
|
||||
public override IDataParameter[] ToIDbDataParameter(params SugarParameter[] parameters)
|
||||
{
|
||||
var isVarchar = this.Context.IsVarchar();
|
||||
if (parameters == null || parameters.Length == 0) return null;
|
||||
SQLiteParameter[] result = new SQLiteParameter[parameters.Length];
|
||||
int index = 0;
|
||||
@@ -107,7 +108,10 @@ namespace SqlSugar
|
||||
sqlParameter.DbType = System.Data.DbType.String;
|
||||
sqlParameter.Value = sqlParameter.Value.ObjToString();
|
||||
}
|
||||
|
||||
if (isVarchar && sqlParameter.DbType == System.Data.DbType.String)
|
||||
{
|
||||
sqlParameter.DbType = System.Data.DbType.AnsiString;
|
||||
}
|
||||
++index;
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user