How to cope with Exceptions in Linq Queries? -


i have found using linq useful experience when querying lists, , provides succinct, readable code.

the issue have found when error occurs hard debug part of query failing.

is there way find out? highlights whole query , returns error.

an example if have list:

class person {     public ilist<string> pets     {         // please, don't @ home :)         { throw new invalidoperationexception(); }     } }  person person = new person();  list<person> mystrings = new list<person>(); mystrings.add(person);  var people = p in mystrings              p.pets.count > 0              select p; 

obviously checking null simple solution, more convoluted errors may not obvious, how should locate in query failing?

is there linq profiler or something?

you can set visual studio break on exceptions, , break exception thrown, inside lambda.

this can uncover subtle bugs; highly recommend it.
however, old, exception-laden code, nightmare.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -