views:

30

answers:

1

Hi, In my ASP.NET MVC 2 C# web app I have a repository that contains method that returns an Iqueryable. My controller calls this, handing over some variables to it so it an run a linq to sql query. How can I check to see if the returning iqueryable has returned anything/contains anything to the controller? Basiclly check if it is returns null?

For the life of me i can't figure it out and it is frustrating because I am guessing that is straightforward to do!!

Thanks,

+1  A: 
var query = db.Foos.Where( ... );

if (query.Any())
{
     ... we got something ...
}
tvanfosson
Your a star! it wasn't exactly what I was after but I have adapted it to my needs and it works fine.
Csharper