title: Use IQueryable on stored procedure in Entity Framework
body: <p>I'm trying to use <code>IQueryable</code> on the stored procedure, the reason for writing a stored procedure is to check multiple conditions in the query. Please correct me if I'm going in a wrong direction.</p>
  
  <p>I assume applying <code>IQueryable</code> will be much faster than the <code>IEnumerable</code> not to forget I was able to use <code>IQueryable</code> on the other entities without any issues.</p>
  
  <p>Controller:</p>
  
  <pre><code>public ActionResult CrmBlogGroupType(int? page, bool? Name, bool? AuthorTitle, bool? Description, string search, int? PageSize, string type)
  {
      try
      {
          if (type==null)
          {
              type = "A";
          }
  
          IQueryable&lt;Usp_getBlogSetPosts_Result&gt; _objBlogSet = _dataLayer.GetBlogSet(type);
          var Result = _objBlogSet.ToPagedList(page ?? 1, PageSize ?? 10);
  
          return View(_objBlogSet);
  }
  </code></pre>
  
  <p>Data layer:</p>
  
  <pre><code>public IQueryable&lt;Usp_getBlogSetPosts_Result&gt; GetBlogSet(string type)
  {
          IQueryable&lt;Usp_getBlogSetPosts_Result&gt; Obj = _dbContext.Usp_getBlogSetPosts(type).AsQueryable();
           return Obj;
  }
  </code></pre>
  
  <p><code>Context.cs</code>:</p>
  
  <pre><code> public virtual ObjectResult&lt;Usp_getBlogSetPosts_Result&gt; Usp_getBlogSetPosts(string blogSetType)
   {
          var blogSetTypeParameter = blogSetType != null ?
              new ObjectParameter("BlogSetType", blogSetType) :
              new ObjectParameter("BlogSetType", typeof(string));
  
          return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction&lt;Usp_getBlogSetPosts_Result&gt;("Usp_getBlogSetPosts", blogSetTypeParameter);
  }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>The result of a query cannot be enumerated more than once</p>
  </blockquote>