L
L
Lev Fedorov2020-05-13 12:05:39
PostgreSQL
Lev Fedorov, 2020-05-13 12:05:39

Should I call commit on a transaction in linq2db?

In a web application, I use PostgreSQL as a DBMS and linq2db ORM for it.
When calling any controller methods that use the database, I use the using construct in which I open the context to the database.
And I have a problem, when I open a context and update some record, then after a while the change is rolled back

using(Context db = new Context()){
  var SomeEntry = db.SomeTable.FirsrtOrDefault(x => x.id == 1);
  SomeEntry.name = "q";
  db.Update(SomeEntry);
}


Should I call Commit after every use of update?

using(Context db = new Context()){
  var SomeEntry = db.SomeTable.FirsrtOrDefault(x => x.id == 1);
  SomeEntry.name = "q";
  db.Update(SomeEntry);
  db.CommitTransaction();
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question