Thursday, 20 January 2011

does not contain a definition for 'SingleOrDefault'

I was calling the LINQ function SingleOrDefault, from code copied elsewhere on objects of the exact same type, so was baffled to recieve this message:

(ObjectType) does not contain a definition for 'SingleOrDefault'

A little googling revealed that all i had to do was make a reference to the System.Linq DLL for the class using the function, as such:

using System.Linq;

And all was well!


  1. thanks, I encountered the same problem and untill found your post..

  2. This helped me as well. Thank you!

    Was faked out by having previously included System.XML.Linq....