I have found using Linq to be a useful experience when querying lists, and provides succinct, readable code.
The issue I have found is when an error occurs it is very hard to debug which part of the query is failing.
Is there a way to find this out? It just highlights the whole query and returns the error.
An example is if I have a list:
class Person
{
public IList<string> Pets
{
// please, don't do this at home :)
get { throw new InvalidOperationException(); }
}
}
Person person = new Person();
List<Person> myStrings = new List<Person>();
myStrings.Add(person);
var people = from p in myStrings
where p.Pets.Count > 0
select p;
Obviously checking for null is a simple solution, but for more convoluted errors that also may not be as obvious, how should we locate where in the query is failing?
Is there a Linq profiler or something?