Keep up the nice work Felipe. Thanks!

On Apr 15, 5:09 am, Felipe Leusin <felipe.leu...@gmail.com> wrote:
> Just one more quick add-in, the code I changed is this
> (AutoMapper.cs : Lin 71):
>
> if (isDiscriminated && !discriminatorSet && mapping is ClassMapping)
>                 {
>                     if (((ClassMapping)mapping).Discriminator != null)
> {
>                         discriminatorSet = true;
>                     }
>                     else {
>                         var discriminatorColumn =
> expressions.DiscriminatorColumn(classType);
>                         var discriminator = new DiscriminatorMapping {
>                             ContainingEntityType = classType,
>                             Type = new TypeReference(typeof(string))
>                         };
>                         discriminator.AddDefaultColumn(new
> ColumnMapping { Name = discriminatorColumn });
>
>                         ((ClassMapping)mapping).Discriminator =
> discriminator;
>                         discriminatorSet = true;
>                     }
>                 }
>
> Now is off to figure out a way to make an Override for Subclass OR
> create a new Convention perhaps to set DiscriminatorValue for the
> subclasses.
>
> On Apr 15, 8:59 am, Felipe Leusin <felipe.leu...@gmail.com> wrote:
>
>
>
> > Just a heads up, after some further digging up I found some
> > inconsistencies in AutoMapper.cs method MapInheritanceTree,
> > there is no check to see if mappings.Discriminator is set whatsoever.
>
> > Now, if I add something simple as:
>
> >                 if (((ClassMapping)mapping).Discriminator != null) {
> >                     discriminatorSet = true;
> >                 }
>
> > Then it works. And I can even change the discriminator using an
> > Override, but I've yet to find a way to create a Subclass Override. If
> > I can find one, then I'm gold.
>
> > Anyway, I'll do some further working on this and let you guys know of
> > any updates.
>
> > Cya,
> > Felipe
>
> > On Apr 14, 4:04 pm, Berryl Hesh <ef747...@gmail.com> wrote:
>
> > > I find the same behavior too - I can't set the column name of the
> > > discriminator and I can't override the default behavior of using the
> > > fully qualified type as the discriminator value.
>
> > > I posted a question here a few weeks ago looking for a way to see if
> > > there was a convention I could use and how to use it but no responses
> > > at all, and definitely not obviously documented. I do get the
> > > inheritance behavior at least! Life in the open source lane ...
>
> > > Cheers,
> > > Berryl
>
> > > On Apr 14, 4:42 am, Felipe Leusin <felipe.leu...@gmail.com> wrote:
>
> > > > A follow-up: If u set the DiscriminatorColumn in the setup part of
> > > > AutoMapper you can change the name of the column, ie:
>
> > > > DiscriminatorColumn = type => (type == typeof(MyClass)) ?
> > > > "IsHomeTeam" : "discriminator";
>
> > > > But I've been having no luck in determining a way to set
> > > > DiscriminatorColumn type and removed the classes altogether from
> > > > AutoMapping (btw, we should really make this easier, the ignoring from
> > > > automapper part).
>
> > > > Best of luck,
> > > > Felipe
>
> > > > On Apr 10, 1:14 pm, reach4thelasers <kev.m.mul...@googlemail.com>
> > > > wrote:
>
> > > > > I've been searching for a solution to this all day.  Does anyone have
> > > > > a solution?
>
> > > > > On Mar 22, 7:06 pm, kberridge <kevin.w.berri...@gmail.com> wrote:
>
> > > > > > Last check, can anyone provide any direction for me on this?
>
> > > > > > Thanks,
> > > > > > Kevin
>
> > > > > > On Mar 9, 6:37 pm, kberridge <kevin.w.berri...@gmail.com> wrote:
>
> > > > > > > Hi,
> > > > > > > I'm looking for an example of how to use a 
> > > > > > > table-per-class-hierarchies
> > > > > > > with Automapper.
>
> > > > > > > I've setup my automappings so the default Subclass Strategy is
> > > > > > > Subclass:
> > > > > > > autoMappings.Setup( s => s.SubclassStrategy = t =>
> > > > > > > SubclassStrategy.Subclass );
>
> > > > > > > I've included the parent of the class Hierarchy with:
> > > > > > > autoMappings.IncludeBase<Parent>();
>
> > > > > > > I have also defined an IAutoMappingOverride for the Parent:
> > > > > > > public class ParentOverrideMap : IAutoMappingOverride<Parent>
> > > > > > > {
> > > > > > >   public void
> > > > > > > Override( FluentNHibernate.Automapping.AutoMapping<Parent> 
> > > > > > > mapping )
> > > > > > >   {
> > > > > > >     mapping.DiscriminateSubClassesOnColumn( "Type" );
> > > > > > >     mapping.SubClass<ChildA>( "ChildA" );
> > > > > > >   }
>
> > > > > > > }
>
> > > > > > > From what I've read on the Wiki on in various Google searches it 
> > > > > > > seems
> > > > > > > like that should work, but when I test it by using the 
> > > > > > > SchemaExport
> > > > > > > tool, it builds the table with the discriminator column name as
> > > > > > > "discriminator" instead of "Type".  So it seems my overrides 
> > > > > > > aren't
> > > > > > > working.
>
> > > > > > > The documentation on the Wiki doesn't cover this, so I've mostly 
> > > > > > > been
> > > > > > > guessing, that's why I'm wondering if anyone could point me to an
> > > > > > > article somewhere with a good example of using the 
> > > > > > > table-per-class-
> > > > > > > hierarchy strategy with automappings.
>
> > > > > > > Thanks,
> > > > > > > Kevin

-- 
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibern...@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