Page 1 of 1

ensure insert order

Posted: Wed 10 Feb 2010 20:35
by tchovis
i wish i could be able to ensure insert order os entities linke
when i do this

university.curses.InsertOnSubmit(curseA);
university.curses.InsertOnSubmit(curseB);
university.curses.InsertOnSubmit(curseC);
university.curses.InsertOnSubmit(curseD);

Db.SubmitChanges();

that the insert comands will be generated for curse A them B them C them D

Posted: Thu 11 Feb 2010 13:13
by AndreyR
In most cases this order will be kept while submitting the changes.
But in some cases (for example, if there are some associations) it may be changed by LINQ to SQL engine.
So, the only way to guarantee the order preservation is to call SubmitChanges explicitly after every InsertOnSubmit.