Print Page | Close Window

Clarity needed around creating and inserting related entities in the same "transaction".

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2265
Printed Date: 07-Apr-2025 at 9:03pm


Topic: Clarity needed around creating and inserting related entities in the same "transaction".
Posted By: pompomJuice
Subject: Clarity needed around creating and inserting related entities in the same "transaction".
Date Posted: 27-Oct-2010 at 3:36am
amagad this forum does not work in chrome at all.
Lets try again in Microsoft Exploder ( which is slow as molasses )
 
I ran some tests before surrounding the following (common) scenario:
 
1: SomeEntity newEntity = EntityManager.DefaultManager.CreateEntity<SomeEntity>();
2: newEntity.someRelatedEntity = EntityManager.DefaultManager.CreateEntity<SomeOtherEntity>();
3: EntityManager.SaveChanges();
 
I get the following exception at line 2: Null or pending entities cannot be modified
 
I might be confused, but I spesifically checked before if devforce can handle such behaviour and it could. Now (6.06) it cant.
 
What am I doing wrong? Both entities recieve their PKs from the database ( they are IDENTITIES).



Replies:
Posted By: pompomJuice
Date Posted: 27-Oct-2010 at 5:33am

Nevermind.

It does work nothing changed, i had a bug in my code.
 
Thanks.



Print Page | Close Window