Little mistake: CreateSpecimen() must take a reference to the original Case 
(the previous code won't compile due to that).

I simplified the original code so it looks like this:

        using (var session = DatabaseSetUpFixture.SessionFactory.OpenSession
())
            using (var tx = session.BeginTransaction())
            {
                Case original = AddSampleCase(session);
                
                original.Specimens = new List<Specimen>() { 
                     new Specimen () { /* additional properties */, Case 
=original 
}
                };

                session.Flush(); // Save the changes
                session.Clear(); // Evict all entities from the session

                Case newVersion = session.Get<Case>(original.Id); // Get 
the DB version
                newVersion.Specimens.Clear(); // Remove all the specimens

                session.Update(newVersion);
                session.Flush(); // StaleStateException here :S

                // ...
                
                tx.Rollback(); // Leave the test DB untouched
            }
        }




El lunes, 30 de diciembre de 2013 12:27:37 UTC-5, Daniel Ricardo Castro 
Alvarado escribió:
>
> Hi,
>
> Keep in mind that I have set inverse=false.
> Anyway, CreateSpecimen() looks like this:
>
> private Specimen CreateSpecimen() {
>    return new Specimen() { /* additional properties */, Case = original }
> }
>
>
>
> El domingo, 29 de diciembre de 2013 23:11:40 UTC-5, 
> [email protected]ó:
>>
>> Hi,
>> Can you give more details about CreateSpecimen()? 
>> As inverse=true requires references to be set in specimen. 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to