+1 to what Martin said

2009/6/16 Martin Hornagold <martin.hornag...@marstangroup.com>

>
> Sounds to me like you don't need subclasses of any kind.
> You just need to tell FNH that DictionaryBase is a base type.
> If you are using S#arpArch you then modifying the IsBaseTypeConvention
> method in the AutoPersistenceModelGenerator to the following should do the
> trick:
>
>        private bool IsBaseTypeConvention(Type arg) {
>            bool derivesFromEntity = arg == typeof(Entity);
>            bool derivesFromEntityWithTypedId = arg.IsGenericType &&
>                (arg.GetGenericTypeDefinition() ==
> typeof(EntityWithTypedId<>));
>            bool derivesFromDictionaryBase = arg == typeof(DictionaryBase)
>
>            return derivesFromEntity || derivesFromEntityWithTypedId ||
> derivesFromDictionaryBase;
>         }
>
> -----Original Message-----
> From: fluent-nhibernate@googlegroups.com [mailto:
> fluent-nhibern...@googlegroups.com] On Behalf Of Lukasz Podolak
> Sent: 16 June 2009 16:18
> To: Fluent NHibernate
> Subject: [fluent-nhib] Re: Table-per-concrete class mapping?
>
>
> Thank you Hudson,
>
> but I still can't make it working. Could you please take a quick look
> at my example ?
> here are my classess (one abstract and one conrete). I have more
> concrete classess like Contractor, but didn't want to include for
> brevity.
>
>  public abstract class DictionaryBase : Entity
>    {
>        protected DictionaryBase() { }
>        public DictionaryBase(string name) { Name = name; }
>
>        [DomainSignature]
>        public virtual string Name { get; set; }
>        public virtual string Description { get; set; }
>    }
>
>    public class Contractor : DictionaryBase
>    {
>        protected Contractor() {}
>        public Contractor(string name) : base(name)
>    }
>
> and the mappings:
>
>    public class DictionaryBaseMap :
> IAutoMappingOverride<DictionaryBase>
>    {
>        public void Override(AutoMap<DictionaryBase> mapping)
>        {
>            mapping.JoinedSubClass<Contractor>("Id", c =>
>            {
>                c.Map(element => element.Name);
>                c.Map(element => element.Description);
>                c.WithTableName(Inflector.Pluralize(typeof
> (Contractor).Name));
>            });
>        }
>    }
>
> This creates me a correct table of "Contractors" with and Id, Name and
> Description but also creates me "DictionaryBases" (which I get mapped
> because of defaults of SharpArch (to look at every object that
> dervices from Entity and apply to it set of conventions, such as table
> name that is pluralized, etc). How can I exclude here mapping for
> DictionaryBase ?
> I took a look at mapping.Not - maybe this way, but I can't find the
> way to succeed.
> thanks once again,
> Łukasz
>
> On 16 Cze, 15:01, Hudson Akridge <hudson.akri...@gmail.com> wrote:
> > In FNH, it would be a .JoinedSubClass("columnName",x=>
> > x.YourSubClassMappingHere);
> > Although as a point of contention, one of the reasons why the table per
> > class hierarchy is default, is because it's the easiest to use in the
> > database, and it's also the best performing option. Having done a fairly
> > complex system using both ways, the table per class hierarchy is far
> better
> > performing.
> >
> > 2009/6/16 Łukasz Podolak <lukasz.podo...@gmail.com>
> >
> >
> >
> > > By default, the inheritance mapping is "table per class hierarchy". I
> > > have a "DictionaryBase" class and couple of derived classes from it.
> > > How can I tell fnh to map all my derived classes as single tables and
> > > not to map DictionaryBase at all ? Can be fluent or automapping,
> > > whichever gets job done. For now I can only accomplish such mapppings
> > > when my concrete dictionary classes .. do not inherit from base, but I
> > > wouldn't like it to live this way.
> >
> > > I'm using SharpArch's defaults if this is any prompt.
> > > thanks for any help
> >
> > > Łukasz
> >
> > --
> > - Hudsonhttp://www.bestguesstheory.comhttp://twitter.com/HudsonAkridge
>
>
> >
>


-- 
- Hudson
http://www.bestguesstheory.com
http://twitter.com/HudsonAkridge

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to