I tried a bunch of things but really don't have a clue what that error I am getting means. Maybe if I could see an example of using a HasMany and then the Reference back with the PersistenceSpecification I could make some sense of it. Not sure what else I might try. Any suggestions would be appreciated.
thanks, Bill On Mar 22, 2:59 pm, Bill <agilemeis...@gmail.com> wrote: > I set Cacasde.All() on the Reference like this: > > // Reference back to parent Project > References(x => x.Project).Cascade.All() > .WithForeignKey("ProjectID").WithColumns("ProjectID"); > > I get the same error > > System.IndexOutOfRangeException: Invalid index 6 for this > SqlParameterCollection with Count=6.. > > Its creating the Project row in the database from the test. > > Here's my class map file > > public class RouteObjMap : ClassMap<RouteObjNH> > { > public RouteObjMap() > { > WithTable("Route"); > UseCompositeId() > .WithKeyProperty(x => x.ProjectID) > .WithKeyProperty(x => x.RouteID); > > Map(x => x.StartTime); > Map(x => x.SlackTime); > Map(x => x.VehicleId); > Map(x => x.MilesTraveled); > > // Reference back to parent Project > References(x => x.Project).Cascade.All() > .WithForeignKey("ProjectID").WithColumns("ProjectID"); > > // Child List of Route Locations > HasMany(x => x.lstRouteLocation) > .WithTableName("RouteLocation") > .WithForeignKeyConstraintName("ProjectID") > .WithForeignKeyConstraintName("RouteID") > .KeyColumnNames.Add("ProjectID", "RouteID"); > } > > And my test > > public void VerifyRouteObjSaves() > { > DateTime dt = new DateTime(2009, 3, 20); > var repository = new NHibernateRepository<RouteObjNH> > (UnitOfWorkFactoryInstance, vRADatabase.Default); > using (var transaction = > UnitOfWorkFactoryInstance.GetSession(vRADatabase.Default)) > { > ISessionBuilder sessionBuilder = new SessionBuilder > (); > ISession session = sessionBuilder.GetSession > (vRADatabase.Default); > > new PersistenceSpecification<RouteObjNH>(session) > .CheckProperty(x => x.ProjectID, "12345") > .CheckProperty(x => x.RouteID, "R00001") > .CheckProperty(x => x.StartTime, dt) > .CheckProperty(x => x.SlackTime, 420) > .CheckProperty(x => x.VehicleId, "53LTL") > .CheckProperty(x => x.MilesTraveled, 34) > .CheckReference(x => x.Project, _project) > .VerifyTheMappings(); > } > > thanks! > Bill > > On Mar 22, 2:42 pm, James Gregory <jagregory....@gmail.com> wrote: > > > > > Hmm, try setting a Cascade on that relationship. > > > On Sun, Mar 22, 2009 at 6:38 PM, Bill <agilemeis...@gmail.com> wrote: > > > > Hi, > > > > I'm new to FNH and NH and have made some progress with getting my > > > classes mapped using Fluent. Then I found the > > > PersistenceSpecification. My question is that when I am just checking > > > against the properties of my class I seem to get the results I expect. > > > If my mapping class has a Reference back to the parent, I seem to get > > > the error: > > > > NHibernate.TransientObjectException: object references an unsaved > > > transient instance - save the transient instance before flushing: > > > vRA.Domain.Project. > > > > If I remove the > > > > References(x => x.Project) > > > .WithForeignKey("ProjectID").WithColumns("ProjectID"); > > > > from my mapping file - all is well. > > > > If add the References back into my map file and then add a > > > > .CheckReference(x => x.Project, _project) > > > > in my PersistenceSpecification I get this error - which I can't quite > > > decipher > > > > System.IndexOutOfRangeException: Invalid index 6 for this > > > SqlParameterCollection with Count=6.. > > > > I'm probably just doing something stupid. Any ideas would be > > > gratefully welcomed. > > > > thanks! > > > Bill- Hide quoted text - > > > - Show quoted text -- 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 -~----------~----~----~----~------~----~------~--~---