Hi Troy Here we go straight from the tests :o), always a good place to put things you can't remember.
var autoMapper = AutoPersistenceModel .MapEntitiesFromAssemblyOf<ExampleClass>() .Where(t => t.Namespace == "FluentNHibernate.AutoMap.TestFixtures.SuperTypes") .WithConvention(c => { c.IsBaseType = b => b == typeof(BaseEntity); }); That should do it for you. Andy On Tue, Jan 6, 2009 at 4:57 PM, Troy Goode <troygo...@gmail.com> wrote: > > Thanks Andrew, that makes sense, but unfortunately I'm still not > getting it to work. I added a convention for GetPrimaryKeyName, but > wasn't able to determine what convention to use to change the > baseobject to BaseEntity from object. When you have some time, any > help would be appreciated. > > Troy > > On Jan 6, 11:44 am, "Andrew Stewart" <andrew.stew...@i-nnovate.net> > wrote: > > Hi Troy > > I'm away from the code right now but the answers your are looking for are > > under the WithConventions method. > > > > From there you can set your baseobject to be BaseEntity rather than > object > > and set GetPrimaryKeyName to be Id. > > > > Hope that helps if not i'll look it up when I'm back at a machine. > > > > Andy > > > > > > > > On Tue, Jan 6, 2009 at 4:35 PM, Troy Goode <troygo...@gmail.com> wrote: > > > > > Alright, I'm stumped. I have everything working fine with normal FNH, > > > but once I tried to spike automapping I ran into an issue. In my > > > project I have a base class for all of my entities like so: > > > > > public abstract class BaseEntity > > > { > > > public virtual int? Id { get; set; } > > > public virtual DateTime? DateCreated { get; set; } > > > public virtual DateTime? DateLastModified { get; set; } > > > public virtual DateTime? DateDeleted { get; set; } > > > } > > > > > So an example of one of my entities would be: > > > > > public class Foo : BaseEntity > > > { > > > public virtual string Name { get; set; } > > > } > > > > > Finally, my autopersit setup looks like so: > > > > > var persistanceModel = AutoPersistenceModel > > > .MapEntitiesFromAssemblyOf<Foo>() > > > .Where( t=> t.Namespace == "MyNamespace" && t.Name != > > > "BaseEntity" ) > > > .ForTypesThatDeriveFrom<BaseEntity>( t=> > > > { > > > t.Id( e => e.Id, "Id" ); > > > t.Map( e=> e.DateCreated > ); > > > t.Map( e=> > > > e.DateLastModified ); > > > t.Map( e=> e.DateDeleted > ); > > > } ); > > > > > The problem I've encountered is that when NH goes to generate its > > > query, it comes up with something like so: > > > > > SELECT > > > this_.BaseEntityId as Id0_0_, > > > this_1_.DateLastModified as DateLast2_0_0_, > > > this_1_.DateDeleted as DateDele3_0_0_, > > > this_1_.DateCreated as DateCrea4_0_0_, > > > this_.Name as Name0_0_ > > > FROM > > > Foo this_ > > > inner join [BaseEntity] this_1_ > > > on this_.BaseEntityId=this_1_.Id > > > > > This will not work as my table structure is simply: > > > > > Foo > > > - Id > > > - Name > > > - DateCreated > > > - DateLastModified > > > - DateDeleted > > > > > Like I said, I have everything working with ClassMap, it is only when > > > I try to use AutoPersistence that the issue arises... so two > > > questions: > > > 1) How do I configure things so that BaseEntity is not assumed to be > > > another table? > > > 2) How do I configure things so that the Id property maps to the "Id" > > > column, rather than (the non-existent) "BaseEntityId" column? > > > > > Thanks! > > > > -- > > ================= > > I-nnovate Software - Bespoke Software Development, uk wirral. > http://www.i-nnovate.net > > > -- ================= I-nnovate Software - Bespoke Software Development, uk wirral. http://www.i-nnovate.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---