c# - Passing dynamic parameters with ExpandoObject -


i have function prototype looks kind of this: public void dothings(string sql, dynamic dparams);

it kind of sql querying parameters. didn't write have use it. works fine when this:

dothings("select * sometable myval1=@v1 , myval2=@v2",         new         {             v1 = new dapper.dbstring()             {                 value = "yay",                 isansi = true,                 length = 50             },             v2 = new dapper.dbstring()             {                 value = "really",                 isansi = true,                 length = 32             }         }); 

but not when first put dynamic params expandoobject:

dynamic dynparams = new expandoobject(); dynparams.v1 = new dapper.dbstring()     {         value = "yay",         isansi = true,         length = 50     } dothings("query here", dynparams);   

the query returns no results. don't want call dothings() , write new block ten times ten different scenarios might want query myval2 or myval3 , on. there special way should passing expandoobject, or other way should doing in general?

dapper doesn't support expandos default, can pass expando constructor of dictionary<string,object> , pass dynamic argument.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -