LINQ in Action roller

Linq to Sql System.InvalidOperationException: Sequence contains no elements

I have been using Linq to SQL very successfully. However, today I have run into what I believe to be a severe bug. Example code: var highScore = (from s in context.SubjectScores where s.SubjectID == StateManager.CurrentSubjectID && s.UserID == Common.CurrentUserKey orderby s.Score descending select s.Score).FirstOrDefault(); This should make highScore = 0 if no records are found. Instead it throws an InvalidOperationException: Sequence contains no elements. Ok, thats not good... but there is no way Read More...
Published Thursday, February 28, 2008 7:35 PM by MSDN Forums: LINQ Project General
Anonymous comments are disabled

Featured Item

This Blog

Sponsoring

Syndication