0

Afternoon,

I have a LINQ query, which counts all products with a certain criteria.

 int processingProductsCount = dc.abcProducts.Where(p => p.prodPublished == 1 && p.pricePublished != true || p.imgPublished != true || p.stockPublished != true).Count();

basically i only want to return a count of items which have the prodPublished of 1 AND pricePublished, imgPublished, stockPublished are all false.

However it is counting all items that have pricePublished, imgPublished, stockPublished are all false. I essentially need to get the result of 0.

I am doing this so i can hide a button, which is only needed when prodPublished is 1 AND pricePublished, imgPublished, stockPublished are all false. But the button displays still as its counting all the items where the pricePublished, imgPublished, stockPublished are all false.

Sorry if this is not written to well, its kind of difficult to explain. Can any one see an issue with my LINQ query?

UPDATE: It looks like the query is bringing back all products which do not have prodPublished as 1

4

1 に答える 1

2

This should do the trick

int processingProductsCount = dc.abcProducts.Count(p => p.prodPublished == 1 && (!p.pricePublished && !p.imgPublished && !p.stockPublished));
于 2012-07-12T14:25:35.580 に答える