title: Linq-To-SQL Marc Gravell's InRange Extension
body: <p>I'm tring to use the <code>InRange</code> extension Marc Gravell wrote here:</p>
  
  <p><a href="https://stackoverflow.com/questions/567963/linq-expression-to-return-property-value/568771#568771">LINQ Expression to return Property value?</a></p>
  
  <p>This is my code so far:</p>
  
  <pre><code>// Fetch list of visit Ids and distinct Ips that fall into the date range
  var q = (from c in db.tblTrackerVisits where c.Date &gt;= MinDate select new { c.ID, c.IPID });
  List&lt;int&gt; VisitIDs = q.Select(c =&gt; c.ID).ToList();
  List&lt;int&gt; DistinctIPs = q.Select(c =&gt; c.IPID).Distinct().ToList();
  
  // List of all campaigns that have visitors
  var Campaigns = db.tblTrackerVariables
      .Where(c =&gt; 
          c.TypeID == Settings.CampaignTrackerVariableTypeID
          //&amp;&amp; db.tblTrackerVisitVariables.Any(d=&gt;VisitIDs.Contains(d.VisitID) &amp;&amp; d.VariableID == c.ID)
          &amp;&amp; db.tblTrackerVisitVariables.InRange(x =&gt; x.VisitID, 1500, VisitIDs)
      )
      .Select(c =&gt; new { c.ID, c.Name }).OrderBy(c=&gt;c.Name);
  </code></pre>
  
  <p>However this throws:</p>
  
  <pre><code>Cannot implicitly convert type 'System.Collections.Generic.IEnumerable&lt;tblTrackerVisitVariable&gt;' to 'bool'
  </code></pre>
  
  <p>I'm not sure if I'm using it correctly, can anyone give me some pointers?  The commented out &amp;&amp; above it:</p>
  
  <pre><code>//&amp;&amp; db.tblTrackerVisitVariables.Any(d=&gt;VisitIDs.Contains(d.VisitID) &amp;&amp; d.VariableID == c.ID)
  </code></pre>
  
  <p>Is the old working code (but it throws the too many params error so I have to resort to this extension method).</p>