Reputation: 1
I am very new to Linq & I am not getting how to show a message if the Linq query does not find any data in the Sql Table. e.g in ADO.Net We used to do like this
ADO.NET :-
if(ds.Tables[0].Rows.count>0)
{
//Do Some Task
}
else
{
MessageBox.Show("No Data Found");
}
LINQ TO SQL;-
DataClasses1DataContext db = new DataClasses1DataContext();
IQueryable<int> catalogNo = db.Product_Details.Select(p => p.pcatalog);
if (What To Check Here?)
{
MessageBox.Show("No Data Found");
}
Can any one please help me? Thanks a ton in advance
Upvotes: 0
Views: 474
Reputation: 664
You can use .Any()
if(catalogNo.Any()){
//I have Data!!!
}else{
//No data found
}
Upvotes: 2