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

Updating Objects - Disconnected API

2 Answers 102 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.
JDT
Top achievements
Rank 1
JDT asked on 19 Feb 2009, 04:49 AM
Hi,

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.

scope.transaction.begin()
scope.add(employee)
scope.transaction.commit()

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 Answers, 1 is accepted

Sort by
0
JDT
Top achievements
Rank 1
answered on 20 Feb 2009, 07:46 AM
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.

Regards.
0
Zoran
Telerik team
answered on 23 Feb 2009, 06:36 PM

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,

Zoran
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.
Tags
Development (API, general questions)
Asked by
JDT
Top achievements
Rank 1
Answers by
JDT
Top achievements
Rank 1
Zoran
Telerik team
Share this question
or