Hi
I have the following problem.
Consider the following code :
//let the user select a node in the tree
SeasonArticleEntity sa = node.Tag as SeasonArticleEntity;
SeasonCarticleEntity sc = sa.SeasonCarticle;
** //sc.Save();
sc.SeasonArticle.Remove(sa);
sc.Save(true);
//refresh the tree
Now this code works when sc is an existing entity in the database. But when sc "isNew" (and consequently sa is also new, because sa cannot exist in our business model without a parent sc) this code gives the following exception:
An exception was caught during the execution of an action query: Cannot insert the value NULL into column 'SEACAR_ID', table 'agro.dbo.SEASON_ARTICLE'; column does not allow nulls. INSERT fails.
The statement has been terminated.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception.
at SD.LLBLGen.Pro.ORMSupportClasses.ActionQuery.Execute()
at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.ExecuteActionQuery(IActionQuery queryToExecute, ITransaction containingTransaction)
at Agro.Datalayer.DaoClasses.SeasonArticleDAO.AddSeasonArticle(IEntityFields fields, ITransaction containingTransaction)
at Agro.Datalayer.EntityClasses.SeasonArticleEntityBase.InsertEntity()
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at Agro.Datalayer.EntityClasses.SeasonArticleEntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.SaveMulti(Boolean recurse)
at Agro.Datalayer.CollectionClasses.SeasonArticleCollection.SaveMulti(Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at Agro.Datalayer.EntityClasses.ArticleEntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at Agro.Datalayer.EntityClasses.ArticleRelationEntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCollectionBase.SaveMulti(Boolean recurse)
at Agro.Datalayer.CollectionClasses.ArticleRelationCollection.SaveMulti(Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at Agro.Datalayer.EntityClasses.ArticleEntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at Agro.Datalayer.EntityClasses.SeasonCarticleEntityBase.Save(IPredicate updateRestriction, Boolean recurse)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase.Save(Boolean recurse)
at Agro.Detailforms.SeizoenForm.btnArtikelVerwijderen_Click(Object sender, EventArgs e)
Uncommenting the indicated line solves this problem, but i do not wish to save at this point. (because the transactional save really happens on a much later time)
Maybe i just didn't get enough sleep but it looks like pretty simple straightforward code, what am i missing ?