How to check results of LINQ to SQL query?

Posted by rem on Stack Overflow See other posts from Stack Overflow or by rem
Published on 2010-03-12T05:55:00Z Indexed on 2010/03/12 5:57 UTC
Read the original article Hit count: 145

Filed under:
|
|

In a WPF app I'd like to check if a return of a LINQ to SQL query contains some records, but my approach doesn't work:

        TdbDataContext context = new TdbDataContext();
        var sh = from p in context.Items where p.Selected == true select p;

        if (sh == null)
        {
            MessageBox.Show("There are no Selected Items");
        }

Where am I wrong?

© Stack Overflow or respective owner

Related posts about c#

Related posts about linq-to-sql