I have this LINQ (LINQ TO ENTITY):
var clientFullReview = (from cr in clientReview
join ir in inspectionReviews on cr.siteId equals ir.SiteId into g
from subsite in g.DefaultIfEmpty()
select new
{
clientId = cr.clientId,
clientName = cr.clientName,
siteId = cr.siteId == null ? -1 : cr.siteId,
inspectionReviewId = (subsite == null ? -1 : subsite.Id),
inspectionFrequency = (subsite == null ? -1 : subsite.FrequencyId),
isNormal = (subsite == null ? false : subsite.IsNormal)
});
In the link above I need to use where clause.
inspectionReviews - has date property. In the LINQ abouve I want to make join only inspectionReviews records that has specific date ,like that:
var clientFullReview = (from cr in clientReview
join ir in inspectionReviews on cr.siteId equals
where ir.DateReview.Year == date.Year &&
ir.DateReview.Month == date.Month
into g
from subsite in g.DefaultIfEmpty()
select new
{
clientId = cr.clientId,
clientName = cr.clientName,
siteId = cr.siteId == null ? -1 : cr.siteId,
inspectionReviewId = (subsite == null ? -1 : subsite.Id),
inspectionFrequency = (subsite == null ? -1 : subsite.FrequencyId),
isNormal = (subsite == null ? false : subsite.IsNormal)
});
But when I try to implement it with where clause I get this error:
A query body must end with a select clause or a group clause
on this key word: into
in second LINQ.
So my question how can I filter data by date when I implement join?