I've already explained this: CustomSqlTypeIs(string) is not an option -
it works for single database type only, and I have two databases: for
unit tests and production one.
I see solution for the case: CustomTypeIs("Date") - it is just
CustomTypeIs<NHibernate.Type.DateType>().
However for CustomTypeIs("Decimal(16,2)") I still have a problem.
I've found possble solutions:
1.
if (IsProductionDatabase) {
Map(x =>x.Balance).CustomSqlTypeIs("Decimal(16,2)");
} else { // unit tests
Map(x =>x.Balance).CustomSqlTypeIs("Numeric");
}
- possible but ugly
2.
Map(x =>x.Balance).SetAttribute("type","decimal(16,3)");
- because I have plenty of SetAttribute in the mapping anyway this
doesn't seem to be that bad
3.
Map(x =>x.Balance).WithScaleOf(16).WithPrecisionOf(3);
- perfect solution but currently not available;
4.
Map(x =>x.Balance).CustomTypeIs("Decimal(16,2)");
- using old revision of FNH
I'm leaning to the solution no 2. But this is worse than the old way.
Could you just revert CustomTypeIs(string) until option 3 will become
available?
I agree that better is to use strongly typed version where possible. For
this purpose you can decorate the method with the [Obsolete] attribute.
Robert
James Gregory pisze:
> It seems like you're asking for more than one thing. Lets straighten
> the first one out, CustomTypeIs(string) is gone, can you use
> CustomSqlTypeIs(string) instead?
>
> 2009/5/5 robsosno <
robs...@gmail.com <mailto:
robs...@gmail.com>>
>
>
> I can write CustomSqlTypeIs("Date") or
> CustomSqlTypeIs("Decimal(16,2)").
> This is correct for my database.
> However this way I'll break my unit tests which are executed using
> SQLite in-memory database (CustomSqlTypeIs("DateTime") and
> CustomSqlTypeIs("Numeric")).
>
> I would use rather this: CustomTypeIs<NHibernate.Type.DateType>()
> and for the second case I need this:
> CustomTypeIs<NHibernate.Type.DecimalType>(scale, precision)
> or rather:
>
> CustomTypeIs<NHibernate.Type.DecimalType>().WithScaleOf(scale).WithPrecisionOf(precision)
> // analogues to WithLengthOf
> but such options do not exist yet.
>
> James Gregory pisze:
> > If you're using it specifically for setting the sql type,
> > CustomSqlTypeIs would be the better method to call. CustomTypeIs is
> > used for overriding the type of the actual property, mainly for
> using
> > IUserType implementations.
> >
> > 2009/5/4 robsosno <
robs...@gmail.com
> <mailto:
robs...@gmail.com> <mailto:
robs...@gmail.com
> > <mailto:
hudson....@gmail.com
> <mailto:
hudson....@gmail.com>>> wrote:
> > >
> > >> I'm not 100% on whether or not this was accidental or
> > intentional, since I'm a bit behind the curve on the new SM.
> > >> 458 was the merge with the new model for Fluent, so it's
> > possible that this broke a few things. Please submit a bug
> report
> > with as much detail as you can muster, as our priority is
> > currently to make sure that things that worked pre-merge, work
> > post-merge. Meaning it would be a high priority for us.
> > >>
> > >> On Mon, May 4, 2009 at 3:20 PM, Rob <
robs...@gmail.com
> <mailto:
robs...@gmail.com>