title: Working with generic viewmodel in mvc
body: <p>I am looking for generic solution for below implementation.</p>
  
  <p>We have stored some of the database table names in one table and this table list we have populated in the dropdownlist and based on the selected table name we want to show the data with there columns in grid and the grid will have CRUD operation buttons. </p>
  
  <p>For these tables we already have the models generated in the project.</p>
  
  <p>But here we want to use generic view model/solution as columns(name,datatype etc) will get vary as per the table selected, so we cannot create a model which will have defined set of properties.</p>
  
  <p>And to retrieve the selected table data we have written the stored procedure. But to retrieve the data returned from the stored procedure we need to provide the model name. Below is sample code</p>
  
  <pre><code>List&lt;SomeModel&gt; modelList = new List&lt;SomeModel&gt;();
  
  modelList = dbcontext.Set&lt;SomeModel&gt;().FromSql("some sp name @tableName={0}", TableName).ToList();
  
  return modelList;
  </code></pre>
  
  <p>So how can we create generic view model which will accept any table/model data and also, how can set that view model in <code>dbcontext.Set&lt;SomeModel&gt;</code> while executing the stored procedure ?</p>