title: Linq Count method and Performance
body: <p>I am using Linq extensively in my project, so far performance is good, i have just one doubt if i have used Linq something like this</p>
  
  <pre><code>var getData = objData.where(obj =&gt; obj.isDelete ==false)
  if (getData != null &amp;&amp; getData.Count() &gt; 0)
     foreach(xyz as obj in getdata.ToList())
     {
        //some operation
     }
  </code></pre>
  
  <p>Does getData.Count() and getdata.ToList() performs two different fetches on object? Or as per deffer loading concept when getData.Count() is executed then no operation is performed for .ToList.</p>
  
  <p>If not then should i remove Count condition, will it improve the performance?</p>
  
  <p>I am using Enterprise Library 5.0 acessor methods to get data from DB
  List lstpack = new List();</p>
  
  <pre><code>            var accessor = _sqlDatabase.CreateSprocAccessor&lt;PackageForClient&gt;("PackageForClientApp", MapBuilder&lt;PackageForClient&gt;
                        .MapAllProperties()
                        .Build()
                 );
  
              var Data = accessor.Execute(startdate, enddate,beinh);
              if (Data != null) //&amp;&amp; Data.Count() &gt; 0 //This has been removed as it is doing an extra fetch
                  lstpack = Data.ToList&lt;PackageForClient&gt;();
  </code></pre>
  
  <p>Now returning the list</p>