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

Save only One Change

3 Answers 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Armin
Top achievements
Rank 1
Armin asked on 21 Oct 2013, 08:37 AM

How do I Save or Reject only one Change ?

3 Answers, 1 is accepted

Sort by
0
Kristian Nikolov
Telerik team
answered on 23 Oct 2013, 01:44 PM
Hi Armin,

When you make a change to the OpenAccess context, a transaction is started automatically. All subsequent changes (inserts, updates, deletes) are added to this transaction until it is closed either by the SaveChanges() or ClearChanges() methods which respectively commit or rollback the transaction. If your scenario allows it, you can design your application in such way that there would always be a single change to the context which would be pushed to the database. For more information about the related features of our Context API you can check the Handling Transactions and Tracking Context Changes articles in our documentation.

Due to those design decisions in the product, in order to achieve a more fine-grain change handling, it should be implemented above the OpenAccessContext, in a layer or a derived wrapper class that takes care for calling SaveChanges or FlushChanges for each change that is performed.

If possible, could you provide details for your scenario so that we may better advise you on the possible approaches? 

I am looking forward to your feedback.

Regards,
Kristian Nikolov
Telerik
OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
0
Armin
Top achievements
Rank 1
answered on 24 Oct 2013, 07:40 AM
My Problem is that i
can edit two different records at the same time.

Scenario :  two different records(Record A and Record B) in edit mode

Now the user want reject record A and save record B.

The problem is RejectChanges() flush all changes
and SaveChanges() save all.

Is it possible to read the changes and save/delete the selected record.

with best regard
0
Accepted
Kristian Nikolov
Telerik team
answered on 24 Oct 2013, 02:20 PM
Hello Armin,

For scenarios like this, we recommend using several separate instances of the context class of your model. In your case you could have two instances of the context responsible for Record A and Record B respectively. This approach will allow you to have fine control over committing and rolling back transactions or just pushing changes to the database.

I hope this helps. In case you have additional questions, do not hesitate to get back to us.

Regards,
Kristian Nikolov
Telerik
OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
Tags
General Discussions
Asked by
Armin
Top achievements
Rank 1
Answers by
Kristian Nikolov
Telerik team
Armin
Top achievements
Rank 1
Share this question
or