IObjectScope.Transaction.Flush() in Q2 2010

2 posts, 0 answers
  1. Alex
    Alex avatar
    22 posts
    Member since:
    Jun 2010

    Posted 13 Aug 2010 Link to this post

    Hello.

    We are investigating possibility to use new version of OpenAccess ORM for our new complex project.
    We are using unit testing in our development process, and we need to run many unit tests in transaction, which is automatically cancelled after unit test is finished, so we can bring database to initial state, so other unit tests may rely on test data.

    Using previous version of OpenAccess ORM and ObjectScope object we was able to call ObjectScope.Transation.Flush() in the middle of unit tests, to generate Identity fields, etc. And then rollback the whole transaction in the end of unit test.

    How this can be done with new Domain Model features in Q2 2010?

    Thanks,

    Alex
  2. Serge
    Admin
    Serge avatar
    375 posts

    Posted 13 Aug 2010 Link to this post

    Hi Alex,

    This is something that is not directly exposed through the context, however there is an easy fix you could implement. The context has an underlying scope that you can access. You have to implement a partial class of the context and in it a property that return an IObjectScope that it would get from the protected method GetScope(). 

    Then you could easily call the old scope.Transaction.Flush() and be sure that context.ClearChanges would revert the changes to the database. We will be considering exposing this in the context so that you needn't use the scope.

    I do hope this helps.

    Sincerely yours,
    Serge
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. DevCraft banner
Back to Top