I have list of rows for insert to database within a transaction using Asp.Net. But it will not commit fully. That means the last fews rows are only inserted.
My code is:
using (PetaPoco.Database db = new Database("Mydb"))
{
using (var trn = db.GetTransaction())
{
foreach(var r in rowlist)
{
db.Save(r);
}
trn.Complete();
}
}
For example rowlist has 20 elements, but some first elements are not inserted using Petapoco. But it will happen very rarely that means very slow network connection.
I don't think that the problem it's in the transaction or Petapoco.
Two guesses:
db.Save
updates or insert depending on the object configuration and ID value? Maybe the last records are updated over the first one inserted