在Linq到实体的SaveChanges()中的序列 [英] sequence in SaveChanges() in linq to entity
问题描述
EF中SaveChanges的顺序是什么?程序员代码中的顺序?有没有办法改变顺序?
table1 t1 = new table1()
table1 t2 = new table2()
table1 t3 = new table3()
// table2和table3引用表1
t1.Table2.add(t2)
t1.Table3.add(t3)
context.AddToTable1(t1)
从SQL服务器跟踪,序列是1)向table1添加行,然后向表2添加一行然后向table3添加行
如何更改表2和表3的插入顺序
谢谢
Hi, what's the sequence in SaveChanges in EF? the order in the programmer's code?
Is there any way to change the order?
table1 t1 = new table1()
table1 t2 = new table2()
table1 t3 = new table3()
//table2 and table3 are referencing table 1
t1.Table2.add(t2)
t1.Table3.add(t3)
context.AddToTable1(t1)
from the SQL server trace, the sequence is 1) add row to table1, then add a row to table 2 then add row to table3
how can I change the insert order on table 2 and table 3?
Thanks
推荐答案
在Entity Framework中,无法将insert语句的顺序更改为服务器。你为什么要这样做?当插入/更新语句存在顺序依赖时,EF将确保使用正确的顺序。
请使用实体框架论坛来解决有关EF的问题 http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/threads/ 点击
感谢您的关注。
In Entity Framework, there is no way to change the order of the insert statement to the server. Why are you trying to do this? EF will make sure that the right order is used when there is a order dependency on the insert/update statements.
Please use the Entity Framework forum to questions regarding EF at http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/threads/
Thanks for your interest.
这篇关于在Linq到实体的SaveChanges()中的序列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!