I don't care you can delete this post again and I will post it again, next 
time that you delete it I will post it twice, if you delete it again, I 
will post it four time, if you delete them I will post it sixteen time and 
so on.
 
How do you map a one to many relation with a no nullable foreign key and 
with cascade delete in the database? There are four case that I would like 
to work correctly:
 
//Case 1: New parent + new child
var p=new Parent();
p.Children.Add(new Child());
session.Save(p);
//Result is two insert query to the database

//Case 2: New child
var p=session.Query<Parent>().First();
p.Children.Add(new Child());
session.Update(p);
//Result is one insert query to the database

//Case 3: Delete child
var p=session.Query<Parent>().First();
p.Children.RemoveAt(0);
session.Update(p);
//Result is one delete query to the database

//Case 4: Delete parent
var p=session.Query<Parent>().First();
session.Delete(p);
//Result is one delete query to the database, the children will be deleted 
from the cascade delete in the database

"save-update" fails the case 3, it doesn't delete the removed items from 
the collection (orphan?)
"all-delete-orphan" doesn't fail any case but in the forth case it generate 
a select query for each children collection of the parent, which are 
useless.
 
 

-- 
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