mirror of
https://github.com/nsnail/FreeSql.git
synced 2025-06-18 20:08:15 +08:00
- 完善 [Column(MapType = typeof(byte[]))] 对 Guid/string 的映射支持;
This commit is contained in:
@ -37,7 +37,10 @@ namespace FreeSql.Oracle
|
||||
if (param == null) return "NULL";
|
||||
if (mapType != null && mapType != param.GetType() && (param is IEnumerable == false || mapType.IsArrayOrList()))
|
||||
param = Utils.GetDataReaderValue(mapType, param);
|
||||
if (param is bool || param is bool?)
|
||||
|
||||
if (param is byte[])
|
||||
return $"hextoraw('{CommonUtils.BytesSqlRaw(param as byte[])}')";
|
||||
else if (param is bool || param is bool?)
|
||||
return (bool)param ? 1 : 0;
|
||||
else if (param is string || param is char)
|
||||
return string.Concat("'", param.ToString().Replace("'", "''"), "'");
|
||||
|
@ -68,7 +68,7 @@ namespace FreeSql.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": return $"to_char({getExp(callExp.Arguments[0])})";
|
||||
}
|
||||
return null;
|
||||
case "NewGuid":
|
||||
|
@ -91,14 +91,7 @@ namespace FreeSql.Oracle
|
||||
public override string GetNoneParamaterSqlValue(List<DbParameter> specialParams, Type type, object value)
|
||||
{
|
||||
if (value == null) return "NULL";
|
||||
if (type == typeof(byte[]))
|
||||
{
|
||||
var bytes = value as byte[];
|
||||
var sb = new StringBuilder().Append("rawtohex('0x");
|
||||
foreach (var vc in bytes)
|
||||
sb.Append(vc.ToString("X").PadLeft(2, '0'));
|
||||
return sb.Append("')").ToString();
|
||||
}
|
||||
if (type == typeof(byte[])) return $"hextoraw('{CommonUtils.BytesSqlRaw(value as byte[])}')";
|
||||
return FormatSql("{0}", value, 1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user