Updating Objects - Disconnected API

Thread is closed for posting
3 posts, 0 answers
  1. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 18 Feb 2009 Link to this post


    So far I am liking the open access framework but I'm having some trouble. Say I have a list of employee objects.
    List<Employee> which are persistable. Using the api I add them to my scope.


    if I then do this.. employee.manager = "newManager";

    I get an error. I read up on the disconnected api but don't want to have to add my objects to a objectContainer since I was only able to make it work by adding them within a scope transaction.

    I simply want to create or load new employee objects, make changes and persist them back to the DB. I could keep a scope transaction open till I call a Save() method but wouldn't this use up resources? What if I want to use a service approach and send modified employee objects over a channel to have them updated? Also what if my objects properties are databound to ui elements, I will get errors because i'm not in active transaction. Please advise.

    Thanks and keep up the good work!
  2. JDT
    JDT avatar
    45 posts
    Member since:
    Jul 2007

    Posted 20 Feb 2009 Link to this post

    Because we wanted to use objects in our code and then send single objects to update we created a custom collection that takes in a sql query to read our objects. When loading from db we create copies into the collection. Then when updating we keep track of the object id. We retrieve the object from db, change its values based on the collection object and then commit back to db.

    Object container is alright for grids and what not. But we didn't want to have an object container in all of our code and then piggy back to the scopeProvider.

    Is there a better way? My thoughts are telerik should have the generic collection we built as part of the API. In order to edit objects in the object container we have to start a transaction and any objects could accidentally be updated instead of the one we intended.

  3. Zoran
    Zoran avatar
    534 posts

    Posted 23 Feb 2009 Link to this post

    Hello Jerry,

    Whenever you commit/rollback a transaction you can not update an object unless you start a new transaction. This can be avoided by setting the scope.TransactionProperties.AutomaticBegin = true when working with the object scope and it must be explicitly started with container.Transaction.Begin() when using disconnected API.
    Concerning your second post we would appreciate if you could send us a sample project where we can see your suggestion for the API in more details. I can assure you that it will be taken into consideration. The object container though is a "must" for the disconnected model. When updating objects, OpenAccess tracks the "Dirty" objects so updating accidentally an unwanted object is practically not possible.

    I am looking forward for your future feedback, I am sure it will help in making OpenAccess more usable to the customers.

    Sincerely yours,

    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top