MySql can Disable Narvchar

This commit is contained in:
sunkaixuan 2019-01-18 14:50:45 +08:00
parent 668d03bfd8
commit 5709e1193c
3 changed files with 18 additions and 4 deletions

View File

@ -9,5 +9,9 @@ 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 MySqlDisableNarvchar { get; set; }
}
}

View File

@ -27,6 +27,11 @@ namespace SqlSugar
}
public override object FormatValue(object value)
{
var n = "N";
if (this.Context.CurrentConnectionConfig.MoreSettings != null && this.Context.CurrentConnectionConfig.MoreSettings.MySqlDisableNarvchar)
{
n = "";
}
if (value == null)
{
return "NULL";
@ -58,11 +63,11 @@ namespace SqlSugar
}
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
{
return "N'" + GetString(value).ToSqlFilter() + "'";
return n+"'" + GetString(value).ToSqlFilter() + "'";
}
else
{
return "N'" + GetString(value) + "'";
return n+"'" + GetString(value) + "'";
}
}
}

View File

@ -90,6 +90,11 @@ namespace SqlSugar
}
public override object FormatValue(object value)
{
var n = "N";
if (this.Context.CurrentConnectionConfig.MoreSettings != null&&this.Context.CurrentConnectionConfig.MoreSettings.MySqlDisableNarvchar)
{
n = "";
}
if (value == null)
{
return "NULL";
@ -121,11 +126,11 @@ namespace SqlSugar
}
else if (type == UtilConstants.StringType || type == UtilConstants.ObjType)
{
return "N'" + GetString(value).ToSqlFilter() + "'";
return n+"'" + GetString(value).ToSqlFilter() + "'";
}
else
{
return "N'" + GetString(value) + "'";
return n+"'" + GetString(value) + "'";
}
}
}