c# - How to know if every queries executed successfully in loop? -
suppose have executed update query in loop using petapoco like,
foreach (var obj in mainobject) { db.execute("update table set column = @0 c1=@1 , c2 =@2", column1, obj.data1, obj.data2); }
how know if each of these queries has been executed ?
usually petapoco
returns 1 or greater if single query executed or means if rows affected , 0 if failed.
with scenario can trace values adding in loop, like:
list<int> checksuccess = new list<int>(); //to trace value returned execute query foreach (var obj in mainobject) { int updated = db.execute("update table set column = @0 c1=@1 , c2 =@2", column1, obj.data1, obj.data2); checksuccess.add(updated); } if (checksuccess.all(i => >= 1)) { //your every queries has been updated }
Comments
Post a Comment