title: mvc4 when to use sprocs versus application code to run complex queries
body: <p>I am new to the whole stored procedures basics; but is there a basic guideline on when to use sproc or regular ole SQL in controller ? For example I have this query which is intensive</p>
  
  <pre><code>     var friendprofile = sqlConnection.Query&lt;following&gt;("Select * from  followings where me=@profile)", new { profile = myid }).ToList();
                      List&lt;thread&gt; comments = new List&lt;thread&gt;();
               foreach(following fp in  friendprofile)
               {
                  var cm=sqlConnection.Query&lt;thread&gt;("select * from threads where profileID=@profile",new {profile =fp.ProfileID}).FirstOrDefault();
                      comments.Add(cm);
              }
  </code></pre>
  
  <p>The query above loops around because each new user can have hundreds of new results and the code gets executed again and again someone suggested that I should create a stored procedure for that code above; would it make sense to do that ?</p>