This seems to be a bug introduced in (or some time before) 1.0 RTM.  I
was using a previous version and the Version property in the base
class was being set up as a <version> in the mapping file.

Creating an AutoMappingOverride for each class defeats the point of
having the Version column in the base class in the first place.

The property is of type int, and it gets picked up by fluent if it's
called something else (like Versionx), but when it's called Version it
just gets ignored (not added as a column either).

On Oct 27, 10:43 am, Neal Blomfield <neal.blomfi...@gmail.com> wrote:
> Chanan,
>
> you need to create an IAutoMappingOverride for each mapped type, these
> look something like:
>
>     public class QuestionAutoMapOverride :
> IAutoMappingOverride<Question>
>     {
>         public void Override( AutoMapping<Question> mapping )
>         {
>             mapping.Version( question => question.Version)
>                 .UnsavedValue( "0" );
>         }
>     }
>
> and then you need to tell the auto mapper to use the overrides - I use
> the UseOverridesFromAssemblyOf<> to achieve this (not sure if there
> are other approaches ):
>
> AutoMap
>   .AssemblyOf<Entity>()
>   .Where( type => typeof(Entity).IsAssignableFrom(type) )
>   IgnoreBase<Entity>()
>   .IgnoreBase( typeof(Entity<>) )
>   .Conventions.Setup( ConfigureConventions )
>   .UseOverridesFromAssemblyOf<DomainMapper>();
>
> On Oct 21, 8:59 am, Chanan <chan...@gmail.com> wrote:
>
>
>
> > Hi Neal,
>
> > I just found the same problem...Versionseems to only wotk when
> > declared in the Entity class and does not when declared in the Base
> > Class.
>
> > By the way, would you be so kind as to post your Mapping override
> > code, its been a long day... :)
>
> > Thanks,
> > Chanan.
>
> > On Oct 18, 7:30 pm, Neal Blomfield <neal.blomfi...@gmail.com> wrote:
>
> > > I have an entity base class that looks as follows:
>
> > >     public abstract class Entity : IEquatable<Entity>
> > >     {
> > >         public Guid Id { get; private set; }
> > >         public longVersion{ get; protected set; }
>
> > >         protected Entity()
> > >         {
> > >             Id = GenerateComb();
> > >         }
>
> > >         public override string ToString()
> > >         {
> > >             // ... elided for brevity
> > >         }
>
> > >         public override bool Equals( object obj )
> > >         {
> > >             return Equals( obj as Entity );
> > >         }
>
> > >         public bool Equals( Entity other )
> > >         {
> > >             if (other == null)
> > >             {
> > >                 return false;
> > >             }
>
> > >             if (ReferenceEquals(other, this))
> > >             {
> > >                 return true;
> > >             }
>
> > >             if (GetType() != other.GetType())
> > >             {
> > >                 return false;
> > >             }
>
> > >             return InternalEquals(other);
> > >         }
>
> > >         protected virtual bool InternalEquals( Entity other )
> > >         {
> > >             // ... elided for brevity
> > >         }
>
> > >         public override int GetHashCode()
> > >         {
> > >             // ... elided for brevity
> > >         }
>
> > >         protected virtual object[] GetSignaturePropertyValues()
> > >         {
> > >             return new object[]{Id,Version};
> > >         }
>
> > >         private Guid GenerateComb()
> > >         {
> > >             // ... elided for brevity ( but its based on the NH /
> > > Jimmy Nilsson implementation )
> > >         }
> > >     }
>
> > >     public abstract class Entity<T> : Entity, IEquatable<T> where T :
> > > Entity<T>
> > >     {
> > >         public virtual bool Equals( T other )
> > >         {
> > >             return base.Equals( other );
> > >         }
> > >     }
>
> > > All entities inherit from Entity<T>.
>
> > > This is automapped via:
>
> > > AutoMap
> > > .AssemblyOf<Entity>()
> > > .Where( type => typeof( Entity ).IsAssignableFrom( type ) )
> > > .IgnoreBase<Entity>()
> > > .IgnoreBase( typeof( Entity<> ) );
>
> > > With this setup, theVersionproperty in the Entity base class is not
> > > being mapped ( noVersioncolumn is being created at all ).  I have
> > > checked that FNH can see the property by changing it to VersionX and
> > > checking it was mapped ( which it was ), I have also ( while
> > > Entity.Versionwas renamed Entity.VersionX ) added aVersionproperty
> > > to one of my entities directly ( i.e. I had a property declared as
> > > Account.Version) and this worked as expected.
>
> > > Any ideas why Entity.Versionis not being mapped as I am at a complete
> > > loss as to why this is happening ( currently I must explicitly map it
> > > with an automapping override ) =(- Hide quoted text -
>
> - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
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