I have a pretty large LINQ query which reads XML nodes into object properties, however a line in my query is causing a System.FormatException exception based on "Input string not in a correct format".
DeliveryFee = x.Descendants("LineItemShipping").Select(e => (double)e.Element("TotalPrice")).FirstOrDefault(),
(double)e.Element("TotalPrice") // this text in the line is highlighted by the debugger so this element must be the cause
There is 1000's of records in the XML document so I am having trouble locating the record causing the exception, is there a way I can "throw" the value causing the error to a catch() statement? I'm not exactly sure how to debug a LINQ query to get the value at runtime and I'm sure it's just an issue where that XML node is empty for this specific record. (or contains an illegal character)
I know it's a specific record as I can pull many rows without an issue however when I try to pull a specific subset that's when I get the exception, so I know it is localized to a months worth of data but I am unable to narrow it down more.