I have the following dictionary declared:
private readonly Dictionary<int, Image> dictionary;
And I have a method, which is causing a compiler error:
public IQueryable<Image> Find(Func<Image, bool> exp)
{
return dictionary.Single(exp);
}
The error i get is:
Error 1 The type arguments for method 'System.Linq.Enumerable.Single<TSource>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,bool>)' cannot be inferred from the usage. Try specifying the type arguments explicitly. C:\work\MSD-AIDS-Images\MSD-AIDS-Images-Test\TestImageRepository.cs 34 30 MSD-AIDS-Images-Test
I have tried googling around, I cant seem to find anything definitive as to what I am doing wrong
Edit - This is monday morning at work.
I meant to put "where", not single
Edit 2!
Ok, the code is now this:
public IQueryable<Image> Find(Func<Image, bool> exp)
{
return dictionary.Values.Where(exp);
}
Now I get the following error:
Error 1 Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<MSD_AIDS_Images_Data.Image>' to 'System.Linq.IQueryable<MSD_AIDS_Images_Data.Image>'. An explicit conversion exists (are you missing a cast?) C:\work\MSD-AIDS-Images\MSD-AIDS-Images-Test\TestImageRepository.cs 34 20 MSD-AIDS-Images-Test
As an FYI, the method there is for implementing an interface, the declaration for that is:
IQueryable<T> Find(Func<T, bool> exp);
This has got more complicated than it should be!