title: Reference problem in C# for IQueryable
body: <p>Code:</p>
  
  <pre><code>public static IQueryable GetAllBy_HesapAdiFirmaAdiCariNo_Turu_bypage_short(string filter, string tip, int page_size, int page_index, string sortcolumn, bool sortdirection)
  {
      //bool tip: 0-tümü, 1-son kullanici, 2-bayi, 3- tedarikçi
      VeriyazDBDataContext db = new VeriyazDBDataContext(); db.Connection.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["LocalSqlServer"].ConnectionString;
      var cariKayitlari = DAL.DAOCari.SelectAll();
      var kayitlar = (from rows in cariKayitlari
                      where rows.HESAPADI.ToLower().Contains(filter.ToLower()) ||
                          (rows.CARITURU == "Bireysel" ? rows.B_ADSOYAD.ToLower().Contains(filter.ToLower()) : 
                                                          rows.K_FIRMAADI.ToLower().Contains(filter.ToLower())) ||
                          (rows.CARITURU == "Bireysel" ?
                          rows.B_ADSOYAD.ToLower().Contains(filter.ToUpper()) :
                          rows.K_FIRMAADI.ToLower().Contains(filter.ToUpper())) ||                                   
                          rows.ID.ToString().Contains(filter)
                      select rows);
  
      switch (tip)
      {
          case ("Tümü"):
          default:
          {
              break;
          }
          case ("Son Kullanici"):
          {
              kayitlar = kayitlar.Where(rows =&gt; rows.SONKULLANICI == true);
              break;
          }
          case ("Bayi"):
          {
              kayitlar = kayitlar.Where(rows =&gt; rows.BAYI == true);
              break;
          }
          case ("Tedarikçi"):
          {
              kayitlar = kayitlar.Where(rows =&gt; rows.TEDARIKCI == true);
              break;
          }
      }
  
      var kayitlar2 = from rows in kayitlar
                      select new
                      {
                          HESAPNO = rows.ID,
                          HESAPADI = rows.HESAPADI,
                          CARIADI = (rows.CARITURU == "Bireysel" ? rows.B_ADSOYAD : rows.K_FIRMAADI)
                          //BAKIYE= "",
                          //PARABIRIMI = rows.LISTEPARABIRIMI
                      };
  
      if (sortcolumn != "")
      {
          if (sortdirection)
              kayitlar2 = kayitlar2.Order(sortcolumn, SortDirection.Ascending).AsQueryable();
          else
              kayitlar2 = kayitlar2.Order(sortcolumn, SortDirection.Descending).AsQueryable();
      }
  
      return kayitlar2.Skip(page_size * (page_index)).Take(page_size);
  }
  </code></pre>
  
  <p>I was calling this method from two different <code>System.Web.UI.Page</code> class in the below method </p>
  
  <ol>
  <li>CariHesaplar</li>
  <li>YeniBilet.</li>
  </ol>
  
  <p><br></p>
  
  <pre><code>private void cari_paging_button_yenile()
  {
      Button_CariIleri.Enabled = true;
      Button_CariGeri.Enabled = true;
  
      if (CariPageIndex == 0)
          Button_CariGeri.Enabled = false;
      string tumu = "Tümü";
  
      if (DAL.DAOCari.GetAllBy_HesapAdiFirmaAdiCariNo_Turu_bypage_short(TextBox_CariArama.Text, tumu, CariPageSize, CariPageIndex + 1, CariSortColumn, CariSortDirection).Count() == 0)//problem occured in this row
          Button_CariIleri.Enabled = false;
  }
  </code></pre>
  
  <p>Problem: When I call <code>GetAllBy_HesapAdiFirmaAdiCariNo_Turu_bypage_short</code> in CariHesaplar I could get the count in the if statement in <code>cari_paging_button_yenile()</code>.However, in YeniBilet when I try to get the Count() I was getting</p>
  
  <blockquote>
    <p>Error 19  'System.Linq.IQueryable' does not contain a definition for
    'Count' and no extension method 'Count' accepting a first argument of
    type 'System.Linq.IQueryable' could be found (are you missing a using
    directive or an assembly reference?)  C:\Users\yigit\Desktop\PROTicari
    (11.04.2011)\UI\MusteriDestek\YeniBilet.aspx.cs   257 17  UI</p>
  </blockquote>
  
  <p>I tried many things to solve this but nothing worked.Afterwards, I thought it could be a missing <code>using</code> statement on the beginning of the page.I checked both of the classes  <code>using</code>s only different was <code>using System.Linq.Dynamic;</code> but they both had <code>using System.Linq;</code> so I thought it couldn't be the problem.But then I wrote <code>using System.Linq.Dynamic;</code> on YeniBilet which was giving the error, too and error disappeared.</p>
  
  <p>My question is why is <code>using System.Linq.Dynamic;</code> reference is not added when a page already has <code>using System.Linq;</code> isn't <code>Linq.Dynamic</code> like a subset of <code>Linq</code>?Why do I have to add it's reference again?</p>