Support System.Ulid

This commit is contained in:
sunkaixuan
2024-07-22 12:27:49 +08:00
parent 88cc162811
commit d590eea5f6
2 changed files with 18 additions and 5 deletions

View File

@@ -852,6 +852,10 @@ namespace SqlSugar
{
propertyInfo.SetValue(addItem, Convert.ToInt32(kv.Value));
}
else if (propertyInfo.PropertyType.FullName == "System.Ulid")
{
propertyInfo.SetValue(addItem,UtilMethods.To( kv.Value, propertyInfo.PropertyType));
}
else
{
propertyInfo.SetValue(addItem, kv.Value);

View File

@@ -597,6 +597,15 @@ namespace SqlSugar
var method = type.GetMethods().FirstOrDefault(it => it.GetParameters().Length == 1 && it.Name == "FromDateTime");
return method.Invoke(null, new object[] { Convert.ToDateTime(value) });
}
else if (destinationType.FullName == "System.Ulid")
{
var method = destinationType.GetMyMethod("Parse", 1);
if (method != null)
{
var result = method.Invoke(null, new object[] { value });
return result;
}
}
var destinationConverter = TypeDescriptor.GetConverter(destinationType);
if (destinationConverter != null && destinationConverter.CanConvertFrom(value.GetType()))
return destinationConverter.ConvertFrom(null, culture, value);