c# - Async action in asp.net mvc controller -
i working on asp.net mvc project created controller action method return jsonresult. action goes db , based on table name passed action should dynamic linq query , return rows desired table.
my action method looks this:
public async task<jsonresult> fieldvalues(string table) { using (dbentities ctx = new dbentities()) { type type = system.reflection.assembly.getexecutingassembly().gettype("mywebapp.models." + table); var query = ctx.set(type).sqlquery(string.format("select * {0}", table)); var data = await query.tolistasync(); return json(data, jsonrequestbehavior.allowget); } }
this action invoked using jquery ($.get(...)) view... tried debug action, table passed properly, query seems ok, return statement never reached!
it's first time using async action method , first time i'm using "dynamic linq".
any on might have done wrong appreciated!
thank you!
ok... found issue! long story cut short: db tables work have column has same name table itself. ef got "scared" , renamed column in generated class , added 1 @ end (class name ar15, , property created ar151 instead of ar15). due this, query failing silently (no exception) - saw when added done , fail methods $.get promise. solution create manually new entity in model structure needed , common tables. once done code worked charm , remove reflection knew entity type (the newly created one).
thanks , suggestions!
Comments
Post a Comment