ah, Ricardo...
Can you make me a personal favor ?
Even if you can you use class-by-class mapping, in NH3.2 the barrier to
use conventions is very low:
mapper.BeforeMapClass += (inspector, type, map) =>
map.Table(type.Name.ToUpper());
mapper.BeforeMapClass += (inspector, type, map) => map.Id(idmap =>
{
idmap.Column("ID"); idmap.Generator(new
HiLoWithSuffixIdGenerator(), g => g.Params(new { max_lo = "1000" }));
});
Then, in each mapping, you can avoid the copy&paste of that chunk.
Thanks.
On Fri, Jul 8, 2011 at 7:45 PM, Ricardo Peres <[email protected]> wrote:
> Hi, Fabio!
>
> Are query-only properties already supported by the new mapping? I have
> this mapping:
>
> mapper.Class<Customer>(ca =>
> {
> ca.Table("`CUSTOMER`");
> ca.Id(x => x.Id, map =>
> {
> map.Column("`ID`");
> map.Generator(new HiLoWithSuffixIdGenerator(), g =>
> g.Params(new
> { max_lo = "1000" }));
> });
> ca.Set<Order>("LastWeekOrders", x =>
> {
> x.Fetch(CollectionFetchMode.Subselect);
> x.Where("(Date >= (GETDATE() - 7))");
> x.Access(Accessor.None);
> x.Inverse(true);
> x.Mutable(false);
> x.Key(y => y.Column("`CUSTOMERID`"));
> });
> ...
> }
>
> This fails with a MappingException: Member not found. The member
> 'RecentOrders' does not exists in type Domain.Customer".
> As you can guess, LastWeekOrders does not exist, this is why I mapped
> it as a string, not with a strongly typed expression. I think that
> when Accessor.None is specified NHibernate should not try to find the
> property, isn't it correct?
>
> Thanks!
>
> RP
--
Fabio Maulo