开发者

How to check if a method return an Iqueryable returns anyhting

开发者 https://www.devze.com 2023-01-06 10:20 出处:网络
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.

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 straig开发者_StackOverflow中文版htforward to do!!

Thanks,


var query = db.Foos.Where( ... );

if (query.Any())
{
     ... we got something ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消