Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic resultset with dapper on 3.5

I've got a store procedure call returning a recordset whith field unknown in advance. For some interop reason I need to make it working on 3.5, so I don't have any dynamic support. Is there some built-in solution in dapper? I did not find any by myself. If there is no such a solution, does it make sense ( and does it work ) to create on the fly a type exposing the property I would fetch ? EDIT I managed to add a completely external solution ( without tweaking the original codebase ) by creating a dynamic object in c# 3.0. Here is the extension dapper code and here the factory for the dynamic object.

like image 940
Felice Pollano Avatar asked Dec 28 '25 04:12

Felice Pollano


1 Answers

Well, actually the dynamic support in dapper is implemented via ExpandoObject, which is basically just a dictionary. It would be pretty simple to tweak the existing code to return IDictionary<string,object> instead of dynamic in the case of 3.5

like image 107
Marc Gravell Avatar answered Dec 31 '25 00:12

Marc Gravell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!