This question is locked. New answers and comments are not allowed.
Hi,
I have a question about updating a persistent object from itself. Let say I have a simple class "User" and I create an object retrieving it by his id like this:
var result =
from c in scope.Extent<User>()
where c.Id == id_user
select c;
User my_user = result.First();
Then I want to have a function "do_login()" in which I want to update the "date_last_login" column of that user. The problem here is I want to have that function inside the User class (so I'm calling it my_user.do_login()), but then I get an error saying: "active transaction required for write operation", when I try to change the value of date_last_login. I believe that the exception is thrown because I am creating my object elsewhere and then after it's created I want to change something using a different scope.
Is there any way it could work like this? Is it possible to retrieve objects and then change them afterwards and commit a transaction without having to use the same scope and doing it in the same function? I want to be able to use an object and change it many times afterwards without knowing when to stop using a scope (and disposing it).
I am having problems understanding the concept of "scope", so maybe someone can show me better example of this? Thanks in advance