日期:2014-05-20  浏览次数:20983 次

关于LINQ提交问题.
public void Insert(List<tb_Salary> list)
  {
  //tb_Salary entity = new tb_Salary();
  //if(db.Connection.State != connectionsta
  //db.Transaction = db.Connection.BeginTransaction();
  //try
  //{
  for (int i = 0; i < list.Count - 1; i++)
  {
   
  db.tb_Salaries.InsertOnSubmit(list[i]);
   
  }
  db.SubmitChanges();
  //db.Transaction.Commit();
  //}
  //catch
  //{
  // db.Transaction.Rollback();
  //}
  }
为什么db.SubmitChanges()后只能提交最后一条纪录?

------解决方案--------------------
public void Insert(List <tb_Salary> list) 

for (int i = 0; i < list.Count - 1; i++) 

db.tb_Salaries.InsertOnSubmit(list[i]); 
db.SubmitChanges();





这样吗???