asp.net mvc - Dynamic SQL binding with MVC model -


in following code, know query output mapped class source. unlike this, have sql[this query not fixed], query output different[different column names , types, , number of columns]. how can make model on fly query not fixed?

public ienumerable<source> get_all_sources() {             string _sql = "select column1,column2 source";             var q = __context.database.sqlquery<source>(_sql);             return q.tolist(); } 

eg: first time : query result : column1, column2, column3, second time might 1 column, column1. want build model grab query output on fly.

you serialize data (eg json) , return serialized string deserialize on other end (wherever ends up).

if return trypes similar enough, have them inherit same superclass.

you use generics (see: dynamic return type of function)


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -