Hi,
I'm new to nHibernate and have been struggling trying to get an insert of a new object Question with child ISet of object QuestionAnswer.
I have the mapping correct and am setting the child set correct I believe passing in the Question object, however when it flushes I get a SQL error below!
could not insert: [Models.QuestionAnswer][SQL: INSERT INTO QuestionAnswer (AnswerText, IsCorrectAnswer, QuestionID) VALUES (?, ?, ?); select SCOPE_IDENTITY()]
Do i need to save the Question object first so the child objects know the value of its FK QuestionID? I would assume that nhibernate could and should insert the question and then use the relevant new ID in the inserting of the child objects.
Any ideas or help would be greatly appreciated.
Thanks,
Kev
|