updating objects problem !

2 posts, 0 answers
  1. goxel
    goxel avatar
    9 posts
    Member since:
    Jan 2009

    Posted 21 Jan 2009 Link to this post

    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();

            }

        }

    }

     

     

  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 21 Jan 2009 Link to this post

    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.
  3. DevCraft banner
Back to Top