What Was I Thinking?

Follies & Foils of .NET Development
posts - 86 , comments - 254 , trackbacks - 0

February 2011 Entries

Fixing LINQ Error: Sequence contains no elements
I’ve read some posts regarding this error when using the First() or Single() command. They suggest using FirstOrDefault() or SingleorDefault() instead. But I recently encountered it when using a Sum() command in conjunction with a Where(): Code Snippet var effectiveFloor = policies.Where(p => p.PricingStrategy == PricingStrategy.EstablishFl... => p.Amount); When the Where() function eliminated all the items in the policies collection, the Sum() command threw the “Sequence contains no ......

Posted On Tuesday, February 15, 2011 8:59 AM | Comments (8) | Filed Under [ Visual Studio ]

Powered by: