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 : items 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== trueis redundant, so if themainis part of the purchase:With the edit, you will need to join, either through a helper member:
Or manually: