CRUD best solution

Thread is closed for posting
2 posts, 0 answers
  1. Michal Ogluszka
    Michal Ogluszka avatar
    7 posts
    Member since:
    Jan 2009

    Posted 02 Jul 2009 Link to this post

    Hi,

     in our latest project we have decided to use OpenAccess, really nice tool, but I have a question. How would You suggest to organize CRUD operations. In fact the biggest problem I have to face is update. If I understand correctly Update of an object has to be between Transaction.Begin(), Commit?

    If so do I need to always select this object from the database (i.e. extent.FirstorDefault or whatever) and than copy all updated properites from the object outside the begin-commit block? Or maybe there is better solution...

    Greetings
    M.
  2. Alexander
    Admin
    Alexander avatar
    727 posts

    Posted 03 Jul 2009 Link to this post

    Hello Michal,

    Yes, all the updates should be made during an active transaction. What I can suggest you to make the process easier is using scope.TransactionProperties.AutomaticBegin = true. When this option is enabled, a transaction is automatically started after Commit() or Rollback(). However, you will still have to call manually scope.Transaction.Commit() to persist the changes.
    You are right about the second question as well. If you have an object which is not 'attached' to an object scope, its changes could not be tracked and you will have to copy them manually to the actual object.

    Sincerely yours,
    Alexander
    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