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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -