mirror of
				https://github.com/nsnail/FreeSql.git
				synced 2025-11-04 17:20:49 +08:00 
			
		
		
		
	- 完善 [Column(MapType = typeof(byte[]))] 对 Guid/string 的映射支持;
This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
using FreeSql.Internal.Model;
 | 
			
		||||
using FreeSql.Internal;
 | 
			
		||||
using FreeSql.Internal.Model;
 | 
			
		||||
using System;
 | 
			
		||||
using System.Collections.Generic;
 | 
			
		||||
using System.Text;
 | 
			
		||||
@@ -55,11 +56,7 @@ namespace FreeSql.Odbc.Default
 | 
			
		||||
        public virtual string ByteRawSql(object value)
 | 
			
		||||
        {
 | 
			
		||||
            if (value == null) return "NULL";
 | 
			
		||||
            var bytes = value as byte[];
 | 
			
		||||
            var sb = new StringBuilder().Append("0x");
 | 
			
		||||
            foreach (var vc in bytes)
 | 
			
		||||
                sb.Append(vc.ToString("X").PadLeft(2, '0'));
 | 
			
		||||
            return sb.ToString();
 | 
			
		||||
            return $"0x{CommonUtils.BytesSqlRaw(value as byte[])}";
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public virtual string CastSql(string sql, string to) => $"cast({sql} as {to})";
 | 
			
		||||
 
 | 
			
		||||
@@ -39,6 +39,7 @@ namespace FreeSql.Odbc.Default
 | 
			
		||||
            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?)
 | 
			
		||||
                return (bool)param ? 1 : 0;
 | 
			
		||||
            else if (param is string)
 | 
			
		||||
@@ -53,6 +54,8 @@ namespace FreeSql.Odbc.Default
 | 
			
		||||
                return Adapter.DateTimeRawSql(param);
 | 
			
		||||
            else if (param is TimeSpan || param is TimeSpan?)
 | 
			
		||||
                return Adapter.TimeSpanRawSql(param);
 | 
			
		||||
            else if (param is byte[])
 | 
			
		||||
                return Adapter.ByteRawSql(param as byte[]);
 | 
			
		||||
            else if (param is IEnumerable)
 | 
			
		||||
                return AddslashesIEnumerable(param, mapType, mapColumn);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user