Also you can take a look at the conventions I created with the new Property/Type conventions.
http://groups.google.com/group/fluent-nhibernate/browse_thread/thread/175754bca2c9305e/9ab7b287b2e12a3a?hl=en&lnk=gst&q=property+convention#9ab7b287b2e12a3a My 2 posts at the bottom of this discussion might give you some ideas. On Feb 3, 5:56 pm, James Gregory <[email protected]> wrote: > It depends really. Fluent NHibernate doesn't touch your database, so it > won't be able to automatically change properties based on column names > unless you've already mapped them. > The best you could do is map your properties as you've done, then create a > ITypeConvention to act on any properties that have a column name ending in > YN. This blog > post<http://blog.jagregory.com/2009/01/11/fluent-nhibernate-auto-mapping-t...> > covers > ITypeConventions. > > There's no way to do this with just plain automapping though. > > On Tue, Feb 3, 2009 at 10:41 PM, c24chan <[email protected]> wrote: > > > Hi, > > > I am quite new to fluent NH, so please bare with me if this is a > > newbie question. > > > I am dealing with a legacy db which consist of table with composite > > primary key. For example, I have 2 domain object DOMAIN and DOMAIN_TL > > and here is the mapping class I have. > > > public class DomainMap : ClassMap<Domain> > > { > > public DomainMap() > > { > > WithTable("DOMAIN_VALUE"); > > UseCompositeId().WithKeyProperty(x => x.DomainName, > > "DOMAIN_NAME").WithKeyProperty(x => x.Value, "VALUE"); > > Map(x => x.IsDefault).TheColumnNameIs > > ("DEFAULT_YN").CustomTypeIs(typeof(NHibernate.Type.YesNoType)); > > > HasMany<DomainTL>(x => x.DomainTLs) > > .WithKeyColumn("DOMAIN_NAME") > > .WithKeyColumn("VALUE") > > .Inverse() > > .LazyLoad(); > > } > > } > > > and > > > public class DomainTLMap : ClassMap<DomainTL> > > { > > public DomainTLMap() > > { > > WithTable("DOMAIN_VALUE_TL"); > > UseCompositeId().WithKeyProperty(x => x.DomainName, > > "DOMAIN_NAME") > > .WithKeyProperty(x => x.Value, "VALUE") > > .WithKeyProperty(x => x.Lang, "LANG"); > > > Map(x => x.CreateDate).TheColumnNameIs("CREATE_DATE"); > > Map(x => x.CreateUser).TheColumnNameIs("CREATE_USER"); > > Map(x => x.DisplayOrder).TheColumnNameIs("DISPLAY_ORDER"); > > Map(x => x.DomainDisplayName).TheColumnNameIs > > ("DISPLAY_VALUE_TL"); > > Map(x => x.ModifyDate).TheColumnNameIs("MODIFY_DATE"); > > Map(x => x.ModifyUser).TheColumnNameIs("MODIFY_USER"); > > Map(x => x.SearchString).TheColumnNameIs("SEARCH_STRING"); > > > References(x => x.Domain).WithColumns("DOMAIN_NAME", > > "VALUE").LazyLoad(); > > } > > } > > > This works fine, but I was wondering if I can let Fluent NH do the > > mapping for me instead. Also, I have a lot of varchar(1) field which > > is always have names end with "_YN" which should be map to a bool > > type. Can this be done with Automapping also? > > > Thanks! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Fluent NHibernate" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/fluent-nhibernate?hl=en -~----------~----~----~----~------~----~------~--~---
