I don't think you should be mapping Name in the SuperClassTypeMap as well as in the subclasses.
On Wed, Mar 11, 2009 at 12:44 PM, Martin Nilsson <mffmar...@gmail.com>wrote: > I'm trying to map the state pattern to NH as this page tells me to do: > > http://www.lostechies.com/blogs/derickbailey/archive/2008/11/26/mapping-a-state-pattern-with-nhibernate.aspx > > But when I'm trying to persist my states I get error: > > "Invalid index 0 for this SqlParameterCollection with Count=0" > > public abstract class SuperClassType > { > public static SuperClassType x = new SubClassType(); > public virtual int Id { get; set; } > public virtual string Name { get; set; } > > protected SuperClassType() > { > } > > protected SuperClassType(int id, string name) > { > Id = id; > Name = name; > } > } > > public class SubClassType : SuperClassType > { > internal SubClassType() : base(1, "SubClass") > { > } > } > > public class SuperClassTypeMap : ClassMap<SuperClassType> > { > public SuperClassTypeMap() > { > CreateMap(); > } > > public void CreateMap() > { > Id(s => s.Id).GeneratedBy.Assigned(); > > Map(x => x.Name); > DiscriminateSubClassesOnColumn("Name") > .SubClass<SubClassType>(m => m.Map(sc => sc.Name)); > } > } > > Can anyone please help me? > > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---