|
@ -164,14 +164,14 @@ namespace SqlSugar |
|
|
List<string> dateThrow = bind.DateThrow; |
|
|
List<string> dateThrow = bind.DateThrow; |
|
|
List<string> shortThrow = bind.ShortThrow; |
|
|
List<string> shortThrow = bind.ShortThrow; |
|
|
MethodInfo method = null; |
|
|
MethodInfo method = null; |
|
|
var transformedPropertyName = bind.GetCSharpType(dbTypeName); |
|
|
var propertyType = bind.GetPropertyType(dbTypeName); |
|
|
var objTypeName = bindType.Name.ToLower(); |
|
|
var objTypeName = bindType.Name.ToLower(); |
|
|
var isEnum = bindType.IsEnum; |
|
|
var isEnum = bindType.IsEnum; |
|
|
if (isEnum) |
|
|
if (isEnum) |
|
|
{ |
|
|
{ |
|
|
transformedPropertyName = "enum"; |
|
|
propertyType = "enum"; |
|
|
} |
|
|
} |
|
|
else if (transformedPropertyName.IsIn("byte[]", "other", "object") || dbTypeName.Contains("hierarchyid")) |
|
|
else if (propertyType.IsIn("byte[]", "other", "object") || dbTypeName.Contains("hierarchyid")) |
|
|
{ |
|
|
{ |
|
|
generator.Emit(OpCodes.Call, getValueMethod); |
|
|
generator.Emit(OpCodes.Call, getValueMethod); |
|
|
generator.Emit(OpCodes.Unbox_Any, bindProperty.PropertyType); |
|
|
generator.Emit(OpCodes.Unbox_Any, bindProperty.PropertyType); |
|
@ -179,10 +179,10 @@ namespace SqlSugar |
|
|
} |
|
|
} |
|
|
if (isNullableType) |
|
|
if (isNullableType) |
|
|
{ |
|
|
{ |
|
|
switch (transformedPropertyName) |
|
|
switch (propertyType) |
|
|
{ |
|
|
{ |
|
|
case "int": |
|
|
case "int": |
|
|
CheckType(intThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(intThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotInt = objTypeName != "int32"; |
|
|
var isNotInt = objTypeName != "int32"; |
|
|
if (isNotInt) |
|
|
if (isNotInt) |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
@ -194,30 +194,30 @@ namespace SqlSugar |
|
|
else |
|
|
else |
|
|
method = getConvertBoolean; break; |
|
|
method = getConvertBoolean; break; |
|
|
case "string": |
|
|
case "string": |
|
|
CheckType(stringThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(stringThrow, objTypeName, propertyType, propertyName); |
|
|
method = getString; break; |
|
|
method = getString; break; |
|
|
case "DateTime": |
|
|
case "DateTime": |
|
|
CheckType(dateThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(dateThrow, objTypeName, propertyType, propertyName); |
|
|
if (objTypeName != "datetime") |
|
|
if (objTypeName != "datetime") |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
|
method = getConvertDateTime; break; |
|
|
method = getConvertDateTime; break; |
|
|
case "decimal": |
|
|
case "decimal": |
|
|
CheckType(decimalThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(decimalThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotDecimal = objTypeName != "decimal"; |
|
|
var isNotDecimal = objTypeName != "decimal"; |
|
|
if (isNotDecimal) |
|
|
if (isNotDecimal) |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
|
method = getConvertDecimal; break; |
|
|
method = getConvertDecimal; break; |
|
|
case "double": |
|
|
case "double": |
|
|
CheckType(doubleThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(doubleThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotDouble = objTypeName != "double"; |
|
|
var isNotDouble = objTypeName != "double"; |
|
|
if (isNotDouble) |
|
|
if (isNotDouble) |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
|
method = getConvertDouble; break; |
|
|
method = getConvertDouble; break; |
|
|
case "Guid": |
|
|
case "Guid": |
|
|
CheckType(guidThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(guidThrow, objTypeName, propertyType, propertyName); |
|
|
if (objTypeName != "guid") |
|
|
if (objTypeName != "guid") |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
@ -227,7 +227,7 @@ namespace SqlSugar |
|
|
case "enum": |
|
|
case "enum": |
|
|
method = getConvertEnum_Null.MakeGenericMethod(bindType); break; |
|
|
method = getConvertEnum_Null.MakeGenericMethod(bindType); break; |
|
|
case "short": |
|
|
case "short": |
|
|
CheckType(shortThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(shortThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotShort = objTypeName != "int16" && objTypeName != "short"; |
|
|
var isNotShort = objTypeName != "int16" && objTypeName != "short"; |
|
|
if (isNotShort) |
|
|
if (isNotShort) |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
|
method = getOtherNull.MakeGenericMethod(bindType); |
|
@ -241,10 +241,10 @@ namespace SqlSugar |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
switch (transformedPropertyName) |
|
|
switch (propertyType) |
|
|
{ |
|
|
{ |
|
|
case "int": |
|
|
case "int": |
|
|
CheckType(intThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(intThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotInt = objTypeName != "int32"; |
|
|
var isNotInt = objTypeName != "int32"; |
|
|
if (isNotInt) |
|
|
if (isNotInt) |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
@ -256,30 +256,30 @@ namespace SqlSugar |
|
|
else |
|
|
else |
|
|
method = getBoolean; break; |
|
|
method = getBoolean; break; |
|
|
case "string": |
|
|
case "string": |
|
|
CheckType(stringThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(stringThrow, objTypeName, propertyType, propertyName); |
|
|
method = getString; break; |
|
|
method = getString; break; |
|
|
case "DateTime": |
|
|
case "DateTime": |
|
|
CheckType(dateThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(dateThrow, objTypeName, propertyType, propertyName); |
|
|
if (objTypeName != "datetime") |
|
|
if (objTypeName != "datetime") |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
|
method = getDateTime; break; |
|
|
method = getDateTime; break; |
|
|
case "decimal": |
|
|
case "decimal": |
|
|
CheckType(decimalThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(decimalThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotDecimal = objTypeName != "decimal"; |
|
|
var isNotDecimal = objTypeName != "decimal"; |
|
|
if (isNotDecimal) |
|
|
if (isNotDecimal) |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
|
method = getDecimal; break; |
|
|
method = getDecimal; break; |
|
|
case "double": |
|
|
case "double": |
|
|
CheckType(doubleThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(doubleThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotDouble = objTypeName != "double"; |
|
|
var isNotDouble = objTypeName != "double"; |
|
|
if (isNotDouble) |
|
|
if (isNotDouble) |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
|
method = getDouble; break; |
|
|
method = getDouble; break; |
|
|
case "guid": |
|
|
case "guid": |
|
|
CheckType(guidThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(guidThrow, objTypeName, propertyType, propertyName); |
|
|
if (objTypeName != "guid") |
|
|
if (objTypeName != "guid") |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
else |
|
|
else |
|
@ -289,7 +289,7 @@ namespace SqlSugar |
|
|
case "enum": |
|
|
case "enum": |
|
|
method = getEnum.MakeGenericMethod(bindType); break; |
|
|
method = getEnum.MakeGenericMethod(bindType); break; |
|
|
case "short": |
|
|
case "short": |
|
|
CheckType(shortThrow, objTypeName, transformedPropertyName, propertyName); |
|
|
CheckType(shortThrow, objTypeName, propertyType, propertyName); |
|
|
var isNotShort = objTypeName != "int16" && objTypeName != "short"; |
|
|
var isNotShort = objTypeName != "int16" && objTypeName != "short"; |
|
|
if (isNotShort) |
|
|
if (isNotShort) |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|
method = getOther.MakeGenericMethod(bindType); |
|
|