Raw ADO.NET transaction object

4 posts, 0 answers
  1. Smail
    Smail avatar
    10 posts
    Member since:
    Apr 2013

    Posted 09 Sep 2013 Link to this post

    Is there any way to obtain the base System.Data.Common.DbTransaction object from an OpenAccessContext instance?

    I need to interface with a legacy module that uses ADO.NET *SqlConnection, *SqlTransaction and so far the only way I can see it working is:

    a) Getting the OpenAccess DbTransaction
    or b) Having a way to return DataTable/DataSet from an OpenAccessContext
  2. Ady
    Admin
    Ady avatar
    588 posts

    Posted 12 Sep 2013 Link to this post

    Hi Smail,

      The underlying DbTransaction is something that the OpenAccessContext controls. Various changes tracked by the context are committed using the transaction and hence it is not exposed directly to the client code.
    Can you provide more information on what is that you want to achieve? Maybe we can provide a solution without having to use the DbTransaction directly.

    Regards,
    Ady
    Telerik
    OpenAccess ORM Q2 2013 brings you a more powerful code generation and a unique Bulk Operations support with LINQ syntax. Check out the list of new functionality and improvements shipped with this release.
  3. DevCraft banner
  4. Smail
    Smail avatar
    10 posts
    Member since:
    Apr 2013

    Posted 01 Oct 2013 Link to this post

    We have legacy code that uses *SqlConnection, *SqlCommand, *SqlDataAdapter and *SqlTransaction. It runs queries and retrieves data from the db (as a DataTable). All the queries run in a transaction as the data it operates on is very sensitive.

    Now that we are using OpenAccess we need to run some LINQ queries with a OpenAccessContext and then call the legacy code, this all needs to happen in one transaction. The legacy code uses a base class that handles the actual creation of SqlConnection/Command/DataAdapter/Transaction and running of the queries. So basically we need a way to hook up the OA transaction object with the legacy code (or find a way to return DataTable/DataSet from OpenAccess).
  5. Ady
    Admin
    Ady avatar
    588 posts

    Posted 04 Oct 2013 Link to this post

    Hello Smail,

     You would need to use System.Transactions in order to fulfill your use case. Enlist both the 'SqlConnection' from your legacy application and the OpenAccess context in the System.Transaction and then you can commit/rollback the System.Transaction. 
    Alternatively you can try and port your legacy code (if possible) to use SqlDataReader instead of SqlDataAdapter.

    Regards,
    Ady
    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