src/Shared/EntityFramework/Core/Mapping/Update/Internal/Propagator.Evaluator.cs
// <summary>
// Casts an object instance to the specified model type.
// </summary>
// <param name="value"> Value to cast </param>
// <param name="clrPrimitiveType"> clr type to which the value is casted to </param>
// <returns> Cast value </returns>
Casts an object instance to the specified model type.
Casts an object instance to the specified model type .
private static object Cast(object value, Type clrPrimitiveType)
            {
                IFormatProvider formatProvider = CultureInfo.InvariantCulture;
                if (null == value
                    || value == DBNull.Value
                    || value.GetType() == clrPrimitiveType)
                {
                    return value;
                }
                else
                {
                    if ((value is DateTime)
                        && (clrPrimitiveType == typeof(DateTimeOffset)))
                    {
                        return new DateTimeOffset(((DateTime)value).Ticks, TimeSpan.Zero);
                    }
                    else
                    {
                        return Convert.ChangeType(value, clrPrimitiveType, formatProvider);
                    }
                }
            }
private static object Cast ( object value , Type clrPrimitiveType ) { IFormatProvider formatProvider = CultureInfo . InvariantCulture ; if ( null == value || value == DBNull . Value || value . GetType ( ) == clrPrimitiveType ) { return value ; } else { if ( ( value is DateTime ) && ( clrPrimitiveType == typeof ( DateTimeOffset ) ) ) { return new DateTimeOffset ( ( ( DateTime ) value ) . Ticks , TimeSpan . Zero ) ; } else { return Convert . ChangeType ( value , clrPrimitiveType , formatProvider ) ; } } }
Casts an object instance to the specified model type.
Casts an object instance to the specified model type .
//Convert is not handling DateTime to DateTimeOffset conversion
None
value
object
Value to cast
Value to cast
clrPrimitiveType
Type
clr type to which the value is casted to
clr type to which the value is casted to