score:2

Accepted answer

Do the job like this:

var subQuery = records.Where(x => x.Datetime >= fromDate && x.Datetime < toDate && x.Message.Contains("fred")).Select(x => x.CorrelationID).Distinct();

var result = records.Where(x => subQuery.Contains(x.CorrelationID)).OrderBy(x => x.Datetime).AsQueryable();

Related Articles