Hi, Fabio! Yes, I also value conventions, and will probably switch to something like you said (no personal favor, though! :-)) Sorry, I didn't understand your question! I was trying to map a query- only property, which does not "physically" exist as a property or as a field, and which should represent a set of all the orders from a given customer whose date was in the last week. Which string parameter are you referring to?
Thanks, RP On 9 Jul, 12:17, Fabio Maulo <[email protected]> wrote: > 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- Ocultar texto citado - > > - Mostrar texto citado -
