title: Handle a lot of data in ASP-NET MVC
body: <p>I'm starting to program with ASP-NET MVC an application with Angular for the front-end and SQL Sever to the database. In some cases, I have complex query than I have to use and I cannot modify because of a restriction business. I am using a structure similar to this one: <a href="https://stackoverflow.com/questions/20772391/using-simple-queries-in-asp-net-mvc">using simple queries in ASP.NET MVC</a> but I don´t know which is the correct way to handle a lot of data and show in the front-end.</p>
  
  <p>I have a ViewModel with the data structure of the results query, a DomainModel where the query is located and the Controller to communicate with the front-end. </p>
  
  <p>My problem is that I don´t know which would be the way to develop what I am trying. Now I´m trying to create as many objects in a list object as rows in my query, but when this method is running my computer gets blocked with no error showed (I can guess it is because it is using the whole memory).</p>
  
  <p>Note that the table in the front has to show only 25 results per page, maybe I can execute the query always when the user choose a diferente page of the table, getting a different lots of results. I didn´t try this choice yet.</p>
  
  <p>This is part of the DomainModel:</p>
  
  <pre><code>public IEnumerable&lt;OperationView&gt; GetOperations()
  {
      List&lt;OperationView&gt; Operationslist = new List&lt;OperationView&gt;();
      using (SqlConnection connection = new SqlConnection(connectionString))
      using (SqlCommand command = new SqlCommand("", connection))
      {
          command.CommandText = /*Query joining 8-10 tables*/;
          connection.Open();
          SqlDataReader reader = command.ExecuteReader();
          while (reader.Read())
          {
              var OperationView = new OperationView();
              OperationView.IdOperacion = reader["ID_OPERACION"].ToString();
              //Loading here some other variables of OperationView
              Operationslist.Add(OperationView);
          }
          connection.Close();
      }
      return Operationslist;
  }
  </code></pre>
  
  <p>This is part of the Controller:</p>
  
  <pre><code>public IEnumerable&lt;OperationView&gt; GetOperaciones()
  {
      var Operation = new OperationPDomainModel();
      return Operation.GetOperations();
  }
  </code></pre>
  
  <p>I think that my front and ViewModel are not importants for this problem, but I can include them if needed.</p>
  
  <p>Currently, if I try to execute the computer shuts down unexpectely...</p>