Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8423321
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:41:37+00:00 2026-06-10T03:41:37+00:00

I have the following: db.Products.Where(p=>p.Sectors.Where(s=>s.website_id == websiteObj.website_id)).Count(); websiteObj is not null and has valid

  • 0

I have the following:

db.Products.Where(p=>p.Sectors.Where(s=>s.website_id == websiteObj.website_id)).Count();

websiteObj is not null and has valid data. There is a many to many relationship between products and sectors. Also, there is a 1 to many relationship between sectors and websites. I don’t have direct access to products from website, I have to go through the website related sectors.

Anyway, this example works:
db.Sectors.Where(p=>p.website_id == websiteObj.website_id)).Count();

But the issue is that the first LINQ query gives me the following errors:
Delegate 'System.Func<BusinessObjects.Product,int,bool>' does not take 1 arguments.
Cannot convert lambda expression to type 'string' because it is not a delegate type.

And a couple other errors.

Anyway, what am I doing wrong? This is my first attempt with LINQ.
Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T03:41:39+00:00Added an answer on June 10, 2026 at 3:41 am

    I think you need Any in the inner query:

    db.Products.Where(p => p.Sectors.Any(s => s.website_id == websiteObj.website_id))
               .Count();
    

    This would return all Products with at least one sector with the specified website_id.

    If you want all Products where all sectors belong to the specified website_id, simply use All instead of Any:

    db.Products.Where(p => p.Sectors.All(s => s.website_id == websiteObj.website_id))
               .Count();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following problem: Our system has products that when released only are
Hey there, I'm trying to make a site which have following: News, Products, About
Lets say I have the following tables: Customers Products CustomerProducts Is there a way
i have following View where user has a table of products and i need
I have the following 3 classes Book Product SpecialOptions There are many Books, and
I have the following code to insert multiple products and prices before submitting the
I have the following tables in my database: Products ID_PRODUCT PRODUCTNAME PRICE Customers ID_CUSTOMER
I have the following (simplified) database tables: Products - ProductID, int, PK - Name,
I have the following query that performs a AND on-demand: var products = //
Suppose you have to following tables where a sale consists of products and a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.