private object ChangeType(object sourceValue, Type targetType)
{
if (sourceValue is byte[] && targetType == typeof(Guid))
{
return new Guid((byte[])sourceValue);
}
if (sourceValue is DateTime && targetType == typeof(DateTimeOffset))
{
return new DateTimeOffset((DateTime)sourceValue);
}
return Convert.ChangeType(sourceValue, targetType, CultureInfo.InvariantCulture);
}