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