jackjohnson44
asked on
linq how to debug selecting objects into new objects
Hi,
I have a ton of xml web service responses which were converted into classes. There are a few issues with these as we are seeing. I commonly do something like the following to display some classes in a grid. Sometimes depending on the input, everything blows up "Object reference not set to an instance of an object.". When this happens, how can i go about trying to debug this? I am guessing there is a null value or something. I am looking for something reusable.
Thanks!
var results = (from os in orderStatus.orderstatus
select new
{
orderNumber = os.orderNumber,
reportedTime = os.reportedTime,
orderstring = os.orderstring,
symbol = os.order.symbol,
quantity = os.order.quantity,
}).ToList();
I have a ton of xml web service responses which were converted into classes. There are a few issues with these as we are seeing. I commonly do something like the following to display some classes in a grid. Sometimes depending on the input, everything blows up "Object reference not set to an instance of an object.". When this happens, how can i go about trying to debug this? I am guessing there is a null value or something. I am looking for something reusable.
Thanks!
var results = (from os in orderStatus.orderstatus
select new
{
orderNumber = os.orderNumber,
reportedTime = os.reportedTime,
orderstring = os.orderstring,
symbol = os.order.symbol,
quantity = os.order.quantity,
}).ToList();
ASKER
Thanks, I am more looking for a way to determine which element is having the issue. i have several of these and want to know what the issue is instead of just checking for null on each element.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window