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 9266047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:13:40+00:00 2026-06-18T14:13:40+00:00

I have the following tables Users – ID – FirstName – LastName MultiplyItems –

  • 0

I have the following tables

Users
 - ID
 - FirstName
 - LastName

MultiplyItems
 - ItemID
 - Title

UserMultiplyItems
 - UserID
 - ItemID

I have a variable

List<int> delegateList = {1, 3, 5};

where 1, 3, 5 are ItemID

I want to select all users, where at least one ItemID linked selectable user.
I try the following:

        var result = from i in _dbContext.Users
                     where 
                     ((delegateList == null) || i.MultiplyItems.Any(p=> delegateList.Any(a => a == p.ItemID)))

                     select new UserModel()
                     {
                         ....
                     };

but it does not work. error:

Cannot compare elements of type ‘System.Collections.Generic.List`1’.
Only primitive types, enumeration types and entity types are
supported.

How to do it correctly?
Thanks

  • 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-18T14:13:41+00:00Added an answer on June 18, 2026 at 2:13 pm

    I would write this one:

    var filteredUsers = delegateList == null 
        ? _dbContext.Users
        : _dbContext.Users.Where(user => user.MultiplyItems
            .Any(item => delegateList.Contains(item.Id)));
    
    var result = filteredUsers.Select(user => new UserModel
            {
                //the UserModel initialization
            });
    

    You should not check the following line inside the query:

    delegateList == null
    

    It is translated to SQL, and SQL has no idea about what is List and how to compare it with null.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following tables: users userId|name items itemId|userId|description What I want to achieve:
I have the following tables: Students StudentID UserID FirstName LastName 1 1 John Doe
I have the following tables: Users: userId , userFirstName , userLastName . holdBilling: bEntityID
I have the following tables: team_members userid teamid users uid name_f name_l friends friend_id
In my application I have the following tables: Posts id title content Users id
I have the following 3 tables: team_data id team_id team_name team_members userid teamid users
I have a table [Users] with the following columns: INT SmallDateTime Bit Bit [UserId],
I have following tables: users(id, name) posts (id, text, userId) comments (id, text, userId,
I use SQL-Server 2008 and have the following tables. users userid 1 2 3
I Have the following tables Users -> UserId -> Name Roles -> RoleId ->

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.