This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am using Dapper.Net for some stored procedure calls in addition to LightSpeed and I want to get access to the unit of work's database connection so I can pass it to Dapper.Net. What is the best way to get a reference to the connection? |
|
|
Do you need to reuse the same connection object (e.g. to participate in the same transaction), or do you just need a connection to the same database? If you only need the latter: IDbConnection conn = uow.Context.DataProviderObjectFactory.CreateConnection(); If you really do need to operate over the same, you'll need to implement a connection strategy that stashes the connection when it creates it, and provides a public method to access the stashed connection. Then: IDbConnection conn = ((PublicisingConnectionStrategy)(uow.ConnectionStrategy)).CurrentConnection; Care may be required in this case to ensure that Dapper doesn't try to open a DataReader on the connection while LightSpeed still has one open, and vice versa. |
|