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

Raw ADO.NET transaction object

3 Answers 32 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.
Smail
Top achievements
Rank 1
Smail asked on 09 Sep 2013, 09:37 AM
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

3 Answers, 1 is accepted

Sort by
0
Ady
Telerik team
answered on 12 Sep 2013, 09:26 AM
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.
0
Smail
Top achievements
Rank 1
answered on 01 Oct 2013, 07:12 AM
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).
0
Ady
Telerik team
answered on 04 Oct 2013, 07:51 AM
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 >>
Tags
General Discussions
Asked by
Smail
Top achievements
Rank 1
Answers by
Ady
Telerik team
Smail
Top achievements
Rank 1
Share this question
or