title: asp.net MVC3 show query result on details page
body: <p>I am new to MVC3</p>
  
  <p>DB has a table called users (id,name,username,lat,lon).  I do not have access to the database.</p>
  
  <p>I created entity model using the above table. Then, I created a SearchController and Search View. On the index page I display the list of all users.  Also, I created a form on the page that searches the table using the username. After clicking on the details link I show the details page where I display the user's details.</p>
  
  <p>Now I need to display other users that are within a mile of the selected user. I already have the sql query to get the list of other users that are within a mile of the selected user (This is a sql query). I need to show this list on Details page. </p>
  
  <p>I created a custom class model.</p>
  
  <pre><code>public class SearchDetailsViewModel
  {
      public decimal id { get; set; }
      public string name { get; set; }
      public string username { get; set; }
      public Nullable&lt;decimal&gt; lat { get; set; }
      public Nullable&lt;decimal&gt; lon { get; set; }
      public string profile_img_url { get; set; }
      public IQueryable&lt;user&gt; usersWithinAMile { get; set; }
  }
  </code></pre>
  
  <p>I am not sure if this is the right approach. Also, I do not know how I would intialize this class.</p>
  
  <p>Any help or suggestion is really appreciated.</p>