This will automatically convert to/from C#'s DateTime.MinValue to NULL.
public class NullDateTimeTypeHandlerCallback : ITypeHandlerCallback
{
public object ValueOf(string nullValue)
{
return nullValue;
}
public object GetResult(IResultGetter getter)
{
if (getter.Value.Equals(System.DBNull.Value))
{
return DateTime.MinValue;
}
else
{
return getter.Value;
}
}
public void SetParameter(IParameterSetter setter, object parameter)
{
if (parameter.Equals(DateTime.MinValue))
{
setter.Value = System.DBNull.Value;
}
else
{
setter.Value = parameter;
}
}
}
<typeHandlers>
<typeHandler
type="DateTime"
callback="Company.Project.NullDateTimeTypeHandlerCallback" />
</typeHandlers>
--- Gilles Bayon <[EMAIL PROTECTED]> wrote:
> Bonjour Nicolas
>
> The best solution is to use a custom type handler that overrides
> IBatisNet's
> DecimalTypeHandler
>
> <typeHandlers>
> <typeHandler
> type="System.Decimal"
> handler="CustomDoubleTypeHanlder" />
> </typeHandlers> (in SqlMap.config)
>
> Ron use such a solution to overrides IBatisNet's DateTimeTypeHandler.
>
> Cheers
> -Gilles
>
> On 1/11/06, [EMAIL PROTECTED]
> <[EMAIL PROTECTED]>
> wrote:
> >
> >
> > Hi
> >
> > I am migrating my application from MIcrosoft Oracle Provider
> > (System.Data.OracleClient) to ODP 10.0.4 (Oracle.DataAccess). and
> I
> > experiment some problems with NUMBER dbType.
> >
> > According to the ODP Documentation, NUMBER should be read with the
> > OracleDataAdapter.GetDecimal() method and not
> > OracleDataAdapter.GetDouble(). With MS Provider, GetDouble works
> propoerly
> >
> > Unfortunately, all my C# objects use double type. with MS Provider,
> I let
> > the AutoMapReader map the query result into my object properties.
> But with
> > ODP, it does not work anymore :( Indeed, The AutoMapReader still
> use
> > GetDouble.
> >
> > So, Can Ibatis convert decimal to double for me at the mapping step
> ? Do I
> > write a Custom Type Handlers ? or is the any other solution more
> clever ?
> >
> > Obviously, I can replace in my code all double type to Decimal
> type, and
> > add everywhere some Convert.ToDouble to avoid interface modfication
> but is
> > is quite boring.
> >
> > Regards
> >
>