This is a migrated thread and some comments may be shown as answers.

updating objects problem !

1 Answer 81 Views
Development (API, general questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
goxel
Top achievements
Rank 1
goxel asked on 21 Jan 2009, 07:37 AM
how i can update objects?
i use below code but it doesnt work.. nothing happens..
i couldnt undestand why, can you help me please


public

void SaveRole(Role role)

 

 

 {

 

 

    IObjectScope scope = null;

 

    try

 

    {

        scope = 

Database.Get("DatabaseConnection1").GetObjectScope();

 

 

        scope.Transaction.Begin();

        role.Definition = "something";

 

 

 

    }

 

 

    catch (Exception ex)

    {

 

 

        ExceptionPolicy.HandleException(ex, "Log Only Policy");

 

    }

 

 

    finally

 

 

 

    {

        if (scope != null)

        {

            scope.Transaction.Commit();

        }

    }

}

 

 

1 Answer, 1 is accepted

Sort by
0
Alexander
Telerik team
answered on 21 Jan 2009, 12:47 PM
Hello goxel,

In the code you provided the role object is not actually associated with the scope. To persist it you have to execute scope.Add(role) somewhere within the transaction and everything should be ok.
You could also take a look at the article about CRUD operations, I hope it is useful.

Sincerely yours,
Alexander
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Development (API, general questions)
Asked by
goxel
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Share this question
or