Attach it to here if you can, if not you can mail it to me directly. On Tue, Jan 26, 2010 at 8:55 PM, Chris F <[email protected]> wrote:
> Hi James, > > I'm putting together a simple S#arpArch project to mimic mine. > > In the meanwhile, I set the Column name and Generated By on the > UserMap and used the (null != instance.Property) again in the > PrimaryKeyConvention, and I finally got my mappings to succeed. > > HOWEVER, there must be all sorts of things wrong with it because the > mappings are incorrect and the app doesn't work (I believe the culprit > is one of my JoinedSubclasses). I've been finding the transition very > painful with multiple fixes required but I can only tackle one at a > time. > > How should I get the demo to you once I've got it together? > > - Chris F. > > On Jan 26, 2:05 pm, James Gregory <[email protected]> wrote: > > Conventions are applied to everything, there's no difference between > > ClassMap and AutoMappings in that regard. > > > > You shouldn't be getting a null Property, that seems like a bug. Can you > > recreate it in a failing test? > > > > On Tue, Jan 26, 2010 at 6:41 PM, Chris F <[email protected]> wrote: > > > Hi, > > > > > I'm on S#arp Arch 1.0 RTM, trying to upgrade to 2009Q3 release. I've > > > been having issues with the change to FNH 1.0 RTM. The various changes > > > to mappings have made my app break. > > > > > Here is one of the several issues I'm trying to solve (that may be > > > related / cascading): > > > > > I have: > > > public class User > > > { > > > public virtual Guid UserId { get; protected set; } > > > public virtual string UserName { get; protected set; } > > > } > > > > > It represents the aspnet_Users table with only the relevant columns to > > > be mapped. This is the only entity that was not being automapped in my > > > pre-upgrade setup using: > > > > > public class UserMap : ClassMap<User> > > > { > > > public UserMap() > > > { > > > Id(x => x.UserId); > > > Map(x => x.UserName); > > > WithTable("aspnet_Users"); > > > } > > > } > > > > > Everything else was getting automapped with some overrides to handle a > > > Money component, and JoinedSubclasses (these are separate upgrade > > > issues I'm dealing with, but one thing at a time here). > > > > > This used to be my PrimaryKeyConvention: > > > public class PrimaryKeyConvention : IIdConvention > > > { > > > public bool Accept(IIdentityPart id) { return true; } > > > > > public void Apply(IIdentityPart id) > > > { > > > id.ColumnName(id.Property.ReflectedType.Name + "Id") > > > .WithUnsavedValue(System.Guid.Empty) > > > .GeneratedBy.GuidComb(); > > > } > > > } > > > > > And my TableNameConvention: > > > public class TableNameConvention : IClassConvention > > > { > > > public bool Accept(IClassMap classMap) { return true; } > > > > > public void Apply(IClassMap classMap) > > > { > > > if (classMap.GetType() == typeof(UserMap)) > > > classMap.WithTable("aspnet_Users"); // This is how I side- > > > stepped the aspnet table > > > else > > > classMap.WithTable(Inflector.Net.Inflector.Pluralize > > > (classMap.EntityType.Name)); > > > } > > > } > > > > > Now I'm having issues with the required changes to work with FNH 1.0. > > > The Mapping process fails right after executing the ClassMap code > > > (which comes before all automapping), followed by the TableName > > > convention code, followed by the PrimaryKeyConvention code. Here is > > > the new code: > > > > > public class PrimaryKeyConvention : IIdConvention > > > { > > > public void Apply(IIdentityInstance instance) > > > { > > > instance.Column(instance.Property.ReflectedType.Name + "Id"); > > > instance.UnsavedValue(System.Guid.Empty.ToString()); > > > instance.GeneratedBy.GuidComb(); > > > } > > > } > > > > > public class TableNameConvention : IClassConvention > > > { > > > public void Apply(IClassInstance instance) > > > { > > > instance.Table(Inflector.Net.Inflector.Pluralize > > > (instance.EntityType.Name)); > > > } > > > } > > > > > The failure is in PrimaryKeyConvention because instance.Property is > > > null. I tried to do an if(instance.Property != null) but that > > > terminates the mapping process early with a "the required attribute > > > 'class' is missing" error. I also had an if (instance.EntityType != > > > typeof(User)) in the TableNameConvention, but took out when it was > > > making no difference. > > > > > What is going on here? First of all, why is the AutoMapping processes > > > calling the conventions for the ClassMap? Second, why is the > > > PrimaryKenConvention getting passed an instance.Property == null? > > > > > Thanks (and sorry for the long post). > > > > > - Chris F. > > > > > -- > > > 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]<fluent-nhibernate%[email protected]> > <fluent-nhibernate%[email protected]<fluent-nhibernate%[email protected]> > > > > > . > > > For more options, visit this group at > > >http://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]<fluent-nhibernate%[email protected]> > . > For more options, visit this group at > http://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.
