mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 兼容 SqlServer varchar/nvarchar 表达式解析,分别解析为:N'' 和 '';
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using FreeSql.Internal.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
@ -43,7 +44,7 @@ namespace FreeSql.Odbc.Default
|
||||
public virtual char QuoteSqlNameRight => ']';
|
||||
|
||||
public virtual string FieldSql(Type type, string columnName) => columnName;
|
||||
public virtual string UnicodeStringRawSql(object value) => value == null ? "NULL" : string.Concat("N'", value.ToString().Replace("'", "''"), "'");
|
||||
public virtual string UnicodeStringRawSql(object value, ColumnInfo mapColumn) => value == null ? "NULL" : string.Concat("N'", value.ToString().Replace("'", "''"), "'");
|
||||
public virtual string DateTimeRawSql(object value)
|
||||
{
|
||||
if (value == null) return "NULL";
|
||||
|
@ -1,4 +1,5 @@
|
||||
using FreeSql.Internal;
|
||||
using FreeSql.Internal.Model;
|
||||
using SafeObjectPool;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@ -29,7 +30,7 @@ namespace FreeSql.Odbc.Default
|
||||
OdbcAdapter Adapter => (_util == null ? FreeSqlOdbcGlobalExtensions.DefaultOdbcAdapter : _util._orm.GetOdbcAdapter());
|
||||
|
||||
static DateTime dt1970 = new DateTime(1970, 1, 1);
|
||||
public override object AddslashesProcessParam(object param, Type mapType)
|
||||
public override object AddslashesProcessParam(object param, Type mapType, ColumnInfo mapColumn)
|
||||
{
|
||||
if (param == null) return "NULL";
|
||||
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false || mapType.IsArrayOrList()))
|
||||
@ -37,7 +38,7 @@ namespace FreeSql.Odbc.Default
|
||||
if (param is bool || param is bool?)
|
||||
return (bool)param ? 1 : 0;
|
||||
else if (param is string)
|
||||
return Adapter.UnicodeStringRawSql(param);
|
||||
return Adapter.UnicodeStringRawSql(param, mapColumn);
|
||||
else if (param is char)
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
else if (param is Enum)
|
||||
@ -52,7 +53,7 @@ namespace FreeSql.Odbc.Default
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
var ie = param as IEnumerable;
|
||||
foreach (var z in ie) sb.Append(",").Append(AddslashesProcessParam(z, mapType));
|
||||
foreach (var z in ie) sb.Append(",").Append(AddslashesProcessParam(z, mapType, mapColumn));
|
||||
return sb.Length == 0 ? "(NULL)" : sb.Remove(0, 1).Insert(0, "(").Append(")").ToString();
|
||||
}
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
|
@ -108,11 +108,11 @@ namespace FreeSql.Odbc.Default
|
||||
if (objType == null) objType = callExp.Method.DeclaringType;
|
||||
if (objType != null || objType.IsArrayOrList())
|
||||
{
|
||||
tsc?.SetMapTypeTmp(null);
|
||||
tsc.SetMapColumnTmp(null);
|
||||
var args1 = getExp(callExp.Arguments[argIndex]);
|
||||
var oldMapType = tsc?.SetMapTypeReturnOld(tsc?.mapTypeTmp);
|
||||
var oldMapType = tsc.SetMapTypeReturnOld(tsc.mapTypeTmp);
|
||||
var left = objExp == null ? null : getExp(objExp);
|
||||
tsc.SetMapTypeReturnOld(oldMapType);
|
||||
tsc.SetMapColumnTmp(null).SetMapTypeReturnOld(oldMapType);
|
||||
switch (callExp.Method.Name)
|
||||
{
|
||||
case "Contains":
|
||||
|
Reference in New Issue
Block a user