Search code examples
c#sessiontransactionsinsert-update

C# Sessions SaveOrUpdate not working


I'm trying to update a database using the Session lybrary and transactions. I have a function that does some work on objects and then updates the DB. Here is my code:

using (_session.BeginTransaction())
                {
                    _session.SaveOrUpdate(foo);
                    _session.Transaction.CommitAsync();
                }

foo is the object i'm trying to update. Now the thing is I call this function more than once using a for loop and the database gets updated only the first time.


Solution

  • I solved it. I'm not really sure what was the problem the only thing i did differently was retriving all objects first before start saving them back.