Save only One Change

4 posts, 1 answers
  1. Armin
    Armin avatar
    11 posts
    Member since:
    Feb 2011

    Posted 21 Oct 2013 Link to this post


    How do I Save or Reject only one Change ?

  2. Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 23 Oct 2013 Link to this post

    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 >>
  3. DevCraft banner
  4. Armin
    Armin avatar
    11 posts
    Member since:
    Feb 2011

    Posted 24 Oct 2013 Link to this post

    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
  5. Answer
    Kristian Nikolov
    Admin
    Kristian Nikolov avatar
    206 posts

    Posted 24 Oct 2013 Link to this post

    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 >>
Back to Top