Michael
Michael

Reputation: 13614

Creating LINQ query with two parameters

I am new to LINQ and I feel some difficulties to write that LINQ query.

I need to write LINQ TO ENTITY to check if table named Reviews where all rows with siteId=5 has at least one row with column named isValid that equal false if there is, I need to return false if not return true.

Upvotes: 0

Views: 105

Answers (1)

Mrinal Kamboj
Mrinal Kamboj

Reputation: 11482

Create a Filter with SiteId

IEnumerable<Review> FilteredReviews = Reviews.Where(x=>x.SiteId == 5)

Check whether any value of IsValid is False, return accordingly

return FilteredReviews.Any(y=>!y.IsValid) ? false : true

Upvotes: 1

Related Questions