Dapper icon indicating copy to clipboard operation
Dapper copied to clipboard

API to obtain a GridReader given a data reader started outside Dapper

Open jnm2 opened this issue 6 years ago • 3 comments

Sometimes we have a DbDataReader or IDataReader that could not have been obtained from Dapper, but we want to map it to types we use with Dapper all the same. Sometimes we directly obtain a SqlDataReader; other times it's a custom reader we wrote or are referencing from NuGet where there is no DbCommand or DbConnection equivalent. As far as I can tell, you can't use Dapper without starting from an (I)DbConnection.

Sometimes we also directly obtain a SqlCommand and would like to be able to use it with Dapper, so an extension method to execute a DbCommand and get back a grid reader would be awesome.

If APIs like this sound good, I'd be happy to put the work in.

jnm2 avatar Jan 02 '20 18:01 jnm2

I just discovered your IDataReader.Parse extension method (can't use, calls non-async Read()), and your IDataReader.GetRowParser extension method (can roll my own extension method with this!) so it looks like this is already covered.

jnm2 avatar Jan 04 '20 21:01 jnm2

Great! Glad this was already covered. Although: it probably wouldn't have been hard to add a constructor of you need the full multi-grid reader capabilities.

On Sat, 4 Jan 2020, 21:24 Joseph Musser, [email protected] wrote:

Closed #1389 https://github.com/StackExchange/Dapper/issues/1389.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/StackExchange/Dapper/issues/1389?email_source=notifications&email_token=AAAEHMG6SN3JMOWG3RQOTKLQ4D5ABA5CNFSM4KCFOX2KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOVYVRV5Q#event-2922060534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAEHMBMOIZ6UEM6BFNCTZLQ4D5ABANCNFSM4KCFOX2A .

mgravell avatar Jan 04 '20 23:01 mgravell

That would have been nice today, in a different project!

jnm2 avatar Oct 23 '24 01:10 jnm2