- 完善 MapType byte[] 对 Contains/Parse 表达式解析的处理;#178

This commit is contained in:
28810 2020-01-07 18:16:37 +08:00
parent 0addfc638a
commit 0dec7ff587
17 changed files with 34 additions and 19 deletions

View File

@ -110,6 +110,9 @@ namespace FreeSql.Tests
var slslsl = g.oracle.Select<SendInfo>().ToList();
var slsls1Ids = slslsl.Select(a => a.ID).ToArray();
var slslss2 = g.oracle.Select<SendInfo>().Where(a => slsls1Ids.Contains(a.ID)).ToList();
var mt_codeId = Guid.Parse("2f48c5ca-7257-43c8-9ee2-0e16fa990253");
Assert.Equal(1, g.oracle.Insert(new SendInfo { ID = mt_codeId, Code = "mt_code", Binary = Encoding.UTF8.GetBytes("我是mt_code") })
.ExecuteAffrows());

View File

@ -37,7 +37,7 @@ namespace FreeSql.MsAccess
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -36,7 +36,7 @@ namespace FreeSql.MySql
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -35,7 +35,7 @@ namespace FreeSql.Odbc.Dameng
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is byte[])

View File

@ -41,7 +41,9 @@ namespace FreeSql.Odbc.Dameng
case "System.UInt16":
case "System.UInt32":
case "System.UInt64": return $"cast({getExp(operandExp)} as number)";
case "System.Guid": return $"to_char({getExp(operandExp)})";
case "System.Guid":
if (tsc.mapType == typeof(byte[])) return $"hextoraw({getExp(operandExp)})";
return $"to_char({getExp(operandExp)})";
}
}
break;
@ -68,7 +70,9 @@ namespace FreeSql.Odbc.Dameng
case "System.UInt16":
case "System.UInt32":
case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as number)";
case "System.Guid": return $"substr(to_char({getExp(callExp.Arguments[0])}), 1, 36)";
case "System.Guid":
if (tsc.mapType == typeof(byte[])) return $"hextoraw({getExp(callExp.Arguments[0])})";
return $"to_char({getExp(callExp.Arguments[0])})";
}
return null;
case "NewGuid":

View File

@ -37,7 +37,7 @@ namespace FreeSql.Odbc.Default
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -37,7 +37,7 @@ namespace FreeSql.Odbc.GBase
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)
return (bool)param ? "'t'" : "'f'";

View File

@ -36,7 +36,7 @@ namespace FreeSql.Odbc.MySql
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -35,7 +35,7 @@ namespace FreeSql.Odbc.Oracle
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is byte[])

View File

@ -41,7 +41,9 @@ namespace FreeSql.Odbc.Oracle
case "System.UInt16":
case "System.UInt32":
case "System.UInt64": return $"cast({getExp(operandExp)} as number)";
case "System.Guid": return $"to_char({getExp(operandExp)})";
case "System.Guid":
if (tsc.mapType == typeof(byte[])) return $"hextoraw({getExp(operandExp)})";
return $"to_char({getExp(operandExp)})";
}
}
break;
@ -68,7 +70,9 @@ namespace FreeSql.Odbc.Oracle
case "System.UInt16":
case "System.UInt32":
case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as number)";
case "System.Guid": return $"substr(to_char({getExp(callExp.Arguments[0])}), 1, 36)";
case "System.Guid":
if (tsc.mapType == typeof(byte[])) return $"hextoraw({getExp(callExp.Arguments[0])})";
return $"to_char({getExp(callExp.Arguments[0])})";
}
return null;
case "NewGuid":

View File

@ -37,7 +37,7 @@ namespace FreeSql.Odbc.PostgreSQL
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -38,7 +38,7 @@ namespace FreeSql.Odbc.SqlServer
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -35,7 +35,7 @@ namespace FreeSql.Oracle
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is byte[])

View File

@ -41,7 +41,9 @@ namespace FreeSql.Oracle
case "System.UInt16":
case "System.UInt32":
case "System.UInt64": return $"cast({getExp(operandExp)} as number)";
case "System.Guid": return $"substr(to_char({getExp(operandExp)}), 1, 36)";
case "System.Guid":
if (tsc.mapType == typeof(byte[])) return $"hextoraw({getExp(operandExp)})";
return $"to_char({getExp(operandExp)})";
}
}
break;
@ -68,7 +70,9 @@ namespace FreeSql.Oracle
case "System.UInt16":
case "System.UInt32":
case "System.UInt64": return $"cast({getExp(callExp.Arguments[0])} as number)";
case "System.Guid": return $"to_char({getExp(callExp.Arguments[0])})";
case "System.Guid":
if (tsc.mapType == typeof(byte[])) return $"hextoraw({getExp(callExp.Arguments[0])})";
return $"to_char({getExp(callExp.Arguments[0])})";
}
return null;
case "NewGuid":

View File

@ -38,7 +38,7 @@ namespace FreeSql.PostgreSQL
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() || param is JToken || param is JObject || param is JArray))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false || param is JToken || param is JObject || param is JArray))
param = Utils.GetDataReaderValue(mapType, param);
bool isdic;

View File

@ -39,7 +39,7 @@ namespace FreeSql.SqlServer
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)

View File

@ -34,7 +34,7 @@ namespace FreeSql.Sqlite
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()))
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false))
param = Utils.GetDataReaderValue(mapType, param);
if (param is bool || param is bool?)