score:3

Accepted answer

No. Basically query expressions exist in order to keep this stuff away from you. There's no particularly simple way of mimicking transparent identifiers.

I find that when you hit transparent identifiers, it's almost always cleaner to use query expression syntax. It's definitely worth knowing both, as very simple queries are cleaner using method syntax, but the more complicated the query, the more likely it is to be easier to read using query expressions.

That's assuming it can all be represented with method expressions, of course. Don't forget you can break up queries into separate statements without changing the meaning, so if you do need to call methods which don't have query expression equivalents, I sometimes find it best to separate it out like this:

var foo = from x in y
          join a in b on x.Z equals a.Z
          select new { a, x };

var bar = foo.Skip(5)
             .Take(10)
             .ToList();

I find that cleaner than just using brackets to mush the two syntax forms together.


Related Articles