score:1

Accepted answer

lines is IQeryable<Line>. If you do not save its result, it will run every time you select from it. If Line does not override Equals and ==, that will create different objects each time, so Except cannot remove the previous object from new objects.

Now, a lot is missing, but try:

var linesList = lines.ToList(); // get results ones
var hasX = lines.Where(line => line.Content.Contains('x'));
var noX = lines.Except(hasX);

score:2

Alright. All I needed to do is to implement IEqualityComparer<T> in Line class.


Related Query

More Query from same tag