mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-05-17 21:49:33 +08:00
BUG: BulkCopy Custom Type
This commit is contained in:
parent
01133dbd17
commit
e60fcb3673
@ -2,6 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Linq.Expressions;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
@ -99,7 +100,16 @@ namespace SqlSugar
|
|||||||
name = column.PropertyName;
|
name = column.PropertyName;
|
||||||
}
|
}
|
||||||
var value = ValueConverter(column, PropertyCallAdapterProvider<T>.GetInstance(column.PropertyName).InvokeGet(item));
|
var value = ValueConverter(column, PropertyCallAdapterProvider<T>.GetInstance(column.PropertyName).InvokeGet(item));
|
||||||
if (isMySql && column.UnderType == UtilConstants.BoolType)
|
if (column.SqlParameterDbType != null&& column.SqlParameterDbType is Type && UtilMethods.HasInterface((Type)column.SqlParameterDbType, typeof(ISugarDataConverter)))
|
||||||
|
{
|
||||||
|
var columnInfo = column;
|
||||||
|
var type = columnInfo.SqlParameterDbType as Type;
|
||||||
|
var ParameterConverter = type.GetMethod("ParameterConverter").MakeGenericMethod(columnInfo.PropertyInfo.PropertyType);
|
||||||
|
var obj = Activator.CreateInstance(type);
|
||||||
|
var p = ParameterConverter.Invoke(obj, new object[] { value, 100 }) as SugarParameter;
|
||||||
|
value = p.Value;
|
||||||
|
}
|
||||||
|
else if (isMySql && column.UnderType == UtilConstants.BoolType)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (value.ObjToBool() == false&& uInt64TypeName.Any(z=>z.EqualCase(column.DbColumnName)))
|
if (value.ObjToBool() == false&& uInt64TypeName.Any(z=>z.EqualCase(column.DbColumnName)))
|
||||||
|
@ -18,6 +18,15 @@ namespace SqlSugar
|
|||||||
{
|
{
|
||||||
public class UtilMethods
|
public class UtilMethods
|
||||||
{
|
{
|
||||||
|
public static bool HasInterface(Type targetType, Type interfaceType)
|
||||||
|
{
|
||||||
|
if (targetType == null || interfaceType == null || !interfaceType.IsInterface)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return interfaceType.IsAssignableFrom(targetType);
|
||||||
|
}
|
||||||
public static void ClearPublicProperties<T>(T obj,EntityInfo entity)
|
public static void ClearPublicProperties<T>(T obj,EntityInfo entity)
|
||||||
{
|
{
|
||||||
if (obj == null)
|
if (obj == null)
|
||||||
|
Loading…
Reference in New Issue
Block a user