Any() and Max() queries

Aug 10, 2011 at 7:06 PM

I'm trying to find the maximum key value in a table. The database is storing data quite happily.

 

int mx = 0;
if
(_database.Query<ImageData, int>().Any()) { mx = _database.Query<ImageData, int>().Max(key => key.Key); }

When I try and compile this I get the following errors:

Error    1    'System.Collections.Generic.List<Wintellect.Sterling.Keys.TableKey<AWP2.ImageData,int>>' does not contain a definition for 'Any' and no extension method 'Any' accepting a first argument of type 'System.Collections.Generic.List<Wintellect.Sterling.Keys.TableKey<AWP2.ImageData,int>>' could be found (are you missing a using directive or an assembly reference?)   
Error    2    'System.Collections.Generic.List<Wintellect.Sterling.Keys.TableKey<AWP2.ImageData,int>>' does not contain a definition for 'Max' and no extension method 'Max' accepting a first argument of type 'System.Collections.Generic.List<Wintellect.Sterling.Keys.TableKey<AWP2.ImageData,int>>' could be found (are you missing a using directive or an assembly reference?)   

Can anyone point me in the right direction here?

Thx++

Aug 10, 2011 at 9:25 PM

You might not have a reference to System.Linq.  Add a using statement at the top of your class.

Aug 11, 2011 at 9:38 AM

Wonderful, that was the problem. Thanks.