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