Is anyone else still having this issue, or is it just me? It's exactly
as Neal describes - when I have the Version property in the base class
it doesn't work, and when it's in the subclass it works fine. As
Deesky says, having to create an override for every entity class seems
to defeat the point of having the base class, so I'd rather avoid
that.

@Paul Batum, what version of FNH are you using? I have 1.0.0.594.

Cheers
Jon


On 6 Jan, 22:14, Paul Batum <[email protected]> wrote:
> My understanding is that this is fixed. I'm using an automapped base
> class with aVersionproperty and it works fine.
>
>
>
> On Thu, Jan 7, 2010 at 7:51 AM, Jeff Doolittle <[email protected]> 
> wrote:
> > Does anyone know if a fix for this if forthcoming?
>
> > --Jeff
>
> > On Nov 13 2009, 10:18 am, Billy <[email protected]> wrote:
> >> I agree with Deeksy.  Theversionproperty from a superclass was
> >> mapping automatically previously.  Seems to require a manual mapping
> >> now or it gets completely ignored.
>
> >> Billy
>
> >> On Nov 5, 10:58 pm, Deeksy <[email protected]> wrote:
>
> >> > This seems to be a bug introduced in (or some time before) 1.0 RTM.  I
> >> > was using a previousversionand theVersionproperty 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 theVersioncolumn 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 calledVersionit
> >> > just gets ignored (not added as a column either).
>
> >> > On Oct 27, 10:43 am, Neal Blomfield <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/fluent-nhibernate?hl=en.
-- 
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.


Reply via email to