title: Entity Framework object LINQ query Timeout issues
body: <p>I've attempted to modify my connection string to include an extended timeout and I've confirmed that on the sql server side the view that feeds my EF Object executes within seconds and returns a total of 3000 or less records.</p>
  
  <p>BUT when I attempt to run it via code I am now running into Timeout issues and I was seeking some advice to fix this issue. I get "Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding."
  Most solutions I find on the specific error recommend connection string modifications OR something along this.context.CommandTimeout... which I cannot figure out how to use in this situation.</p>
  
  <p>I've included the Method I use to acquire the desired data. If there is a more efficient way please let me know.</p>
  
  <p>The input arguments are:</p>
  
  <ul>
  <li><code>int? inputSKU = null</code></li>
  <li><code>int? inputStoreNum = null</code></li>
  <li><code>DateTime? inputStartDate = null</code></li>
  </ul>
  
  <p>The intent is to return the full list.</p>
  
  <p>And it hangs at, because it skips all the conditional bits:
  <code>var qUniqueOffers = query.GroupBy(q =&gt; q.Plan_Number).ToList();</code></p>
  
  <p>Thank you.</p>
  
  <hr>
  
  <pre><code>private List&lt;PromotionItem&gt; QueryPromotion(int? inputSKU, int? inputStoreNum, DateTime? inputStartDate)
  {
      log.Info("Client requested QueryPromotion");
      List&lt;PromotionItem&gt; resultQuery = new List&lt;PromotionItem&gt;();
  
      try
      {
          using (DWH_Entities db = new DWH_Entities())
          {
              var query = db.vw_Web_Promotion.AsQueryable();
  
              // filter promotion results that don't match SKU#
              if (inputSKU != null)
                  query = query.Where(q =&gt; q.Sku_Number == inputSKU);
              // filter promotion results that don't match Store Num
              if (inputStoreNum != null)
                  query = query.Where(q =&gt; q.Store_Number == inputStoreNum);
              // filter promotion results that don't match Promotion Start Date
              if (inputStartDate != null)
                  query = query.Where(q =&gt; q.Start_Date &gt;= inputStartDate);
              // Group promotions By Plan Number ('Promotion ID')
              var qUniqueOffers = query
                                  .GroupBy(q =&gt; q.Plan_Number)
                                  .ToList();
              // Select first from each group to get unique details
              var qOffers = qUniqueOffers
                          .Select(g =&gt; g.OrderBy(gi =&gt; gi.Plan_Number).First())
                          .ToList();
  
              foreach (var qo in qOffers)
              {
                  resultQuery.Add(new PromotionItem
                  {
                      PromotionNumber = qo.Plan_Number.Trim(),
                      PromotionDescription = qo.Plan_Description.Trim(),
                      StartDate = qo.Start_Date,
                      EndDate = qo.End_Date
                  });
              }
          }
      }
      catch (Exception e)
      {
          log.Error("[" + e.TargetSite + "] | " + e.Message);
          throw e;
      }
  
      return resultQuery;
  }
  </code></pre>