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:
		@@ -40,6 +40,7 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
            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)
 | 
			
		||||
@@ -66,6 +67,8 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
            }
 | 
			
		||||
            else if (param is TimeSpan || param is TimeSpan?)
 | 
			
		||||
                return ((TimeSpan)param).TotalSeconds;
 | 
			
		||||
            else if (param is byte[])
 | 
			
		||||
                return $"0x{CommonUtils.BytesSqlRaw(param as byte[])}";
 | 
			
		||||
            else if (param is IEnumerable) 
 | 
			
		||||
                return AddslashesIEnumerable(param, mapType, mapColumn);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -83,15 +83,8 @@ namespace FreeSql.Odbc.SqlServer
 | 
			
		||||
        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("0x");
 | 
			
		||||
                foreach (var vc in bytes)
 | 
			
		||||
                    sb.Append(vc.ToString("X").PadLeft(2, '0'));
 | 
			
		||||
                return sb.ToString();
 | 
			
		||||
            }
 | 
			
		||||
            else if (type == typeof(TimeSpan) || type == typeof(TimeSpan?))
 | 
			
		||||
            if (type == typeof(byte[])) return $"0x{CommonUtils.BytesSqlRaw(value as byte[])}";
 | 
			
		||||
            if (type == typeof(TimeSpan) || type == typeof(TimeSpan?))
 | 
			
		||||
            {
 | 
			
		||||
                var ts = (TimeSpan)value;
 | 
			
		||||
                value = $"{ts.Hours}:{ts.Minutes}:{ts.Seconds}.{ts.Milliseconds}";
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user