编辑其他人的代码,我想知道在使用 for 循环和 InsertOnSubmit 时,submitchanges 调用是进入循环内部还是外部。
IE:
foreach (string t in newTags)
{
Tag q_tag = new Q_Tag();
q_tag.Q_ID = updated.Q_ID;
q_tag.Tag_Name = t;
TheData.Q_Tags.InsertOnSubmit(q_tag);
TheData.SubmitChanges();
}
相对于:
foreach (string t in newTags)
{
Tag q_tag = new Q_Tag();
q_tag.Q_ID = updated.Q_ID;
q_tag.Tag_Name = t;
TheData.Q_Tags.InsertOnSubmit(q_tag);
}
TheData.SubmitChanges();