public override Expression GetReadExpression(Expression dataReader, int ordinal)
{
if (Nullable.GetUnderlyingType(this.SupportedType) == null)
{
return Expression.Condition
(
Expression.Call(dataReader, IsDbNullMethod, Expression.Constant(ordinal)),
Expression.Convert(Expression.Constant(this.SupportedType.GetDefaultValue()), this.SupportedType),
Expression.New
(
timeSpanConstructor,
Expression.Call(dataReader, getValueMethod, Expression.Constant(ordinal))
)
);
}
else
{
return Expression.Condition
(
Expression.Call(dataReader, IsDbNullMethod, Expression.Constant(ordinal)),
Expression.Constant(null, this.SupportedType),
Expression.New
(
nullableTimeSpanConstructor,
Expression.New
(
timeSpanConstructor,
Expression.Call(dataReader, getValueMethod, Expression.Constant(ordinal))
)
)
);
}
}
}