This is a kind of call to judgment, but many questions of “best practice” usually have, at least in the beginning. My opinion is that you should use one or the other as part of a single application. Not for any “danger” inherent in mixing, but for clarity.
In this particular case, the where clause is very simple, and I would reorganize it into the query syntax.
However, there are cases that cannot be elegantly expressed in the query syntax. In cases where it is simply impossible to mix syntaxes, queries (again IMO) can be more readable if you split the method chain into your own variable and then just refer to that variable in the syntax query. Using your model as a model:
//The method chain can be pulled out as its own variable... var filteredParents = _myObject.ObjectsParent.ParentsEnumerable .Where(c => c == anotherObject || c.Parent == anotherObject); //...which you can then substitute in a now purely query-syntax statement from c in filteredParents from q in c.MyObjectsEnumerable orderby c.SortKey, q.Description select new { Item = q, Text = c.Description + " -> " + q.Description };
Keiths
source share