I have the next code:
b.Text = myDataContext.purchases.Count().ToString();
the "b" is label that i have on aspx page. 
I want to add to the code : where items.main == true , like i have here:
        var bla = from items in myDataContext.items
                   where items.main == true
                   select items;
How can i do that on the :     b.Text = myDataContext.purchases.Count().ToString();
i have table : 开发者_如何学Citems with column itemId and column main (bit).
and table: purchase.
on purchase i have column itemId (with relationship)
There is an overload of Count() that takes a predicate (filter); and the == true is redundant, so if the main is part of the purchase:
b.Text = myDataContext.purchases.Count(p => p.main).ToString();
With the edit, you will need to join, either through a helper member:
b.Text = myDataContext.purchases.Count(p => p.item.main).ToString();
Or manually:
  b.Text = (from p in myDataContext.purchases
            join i in myDataContext.items on p.itemId equals i.itemId
            where i.main
            select p).Count().ToString();
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论