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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:12:49+00:00 2026-06-14T21:12:49+00:00

Possible Duplicate: Only primitive types (‘such as Int32, String, and Guid’) are supported in

  • 0

Possible Duplicate:
Only primitive types (‘such as Int32, String, and Guid’) are supported in this context

Ok so I have a user table and a users_users table which basically just ties 2 users together.

My entityframework does not have a users_users in the Model, it only shows up as a relationship/property of the main user object. this relationship shows up as u.user1

so u.user1 is a collection of users where they exist in the users_users table.
this is great but..

I am trying to create a query where I can select all users from a user table, and as well create a boolean variable (called added in code below) in the select clause that will show whether there is a record for the user_user connection.

I am getting the error “Unable to create a constant value of type Only primitive types”

I understand I cannot use a in memory object with a Linq query when using the “Any()” command in the select so how would I go about doing this? I am new to LINQ.

using (myEntities entities = new myEntities())
        {
             Model.user u = entities.users.Single(m => m.emailLogon == System.Web.HttpContext.Current.User.Identity.Name);
             ObjectQuery<Model.user> susers = entities.users;

            var pplquery = (from suser in susers
                            select new { userId = suser.IdUser, FirstName = suser.contactinfo.FirstName, LastName = suser.contactinfo.LastName, added = 
                                u.user1.Any(cusr => cusr.IdUser == suser.IdUser)}).Take(15);


        }
  • 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-14T21:12:51+00:00Added an answer on June 14, 2026 at 9:12 pm
    using (myEntities entities = new myEntities())
            {
                 Model.user u = entities.users.Single(m => m.emailLogon == System.Web.HttpContext.Current.User.Identity.Name);
                 var susers = entities.users.ToList();
    
                var pplquery = (from suser in susers.AsQueryable()
                                select new { userId = suser.IdUser, FirstName = suser.contactinfo.FirstName, LastName = suser.contactinfo.LastName, added = 
                                    u.user1.Any(cusr => cusr.IdUser == suser.IdUser)}).Take(15);
    
    
            }
    

    Turn it into a list to execute the query, then you can create new objects selecting from that set.

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

Sidebar

Related Questions

Possible Duplicate: SQL Server: Only last entry in GROUP BY I have a table
Possible Duplicate: Replace only first match using preg_replace I have a string as follows:
Possible Duplicate: Replacing unquoted words only in Python This is what I have right
Possible Duplicate: Should a function have only one return statement? This is what I
Possible Duplicate: Storing primitive values in a Java collection? ArrayList accepts only reference types
Possible Duplicate: Can Read-Only Properties be Implemented in Pure JavaScript? I have an Object
Possible Duplicate: HTML Text Input allow only Numeric input I used this script function
Possible Duplicate: Mobile site - force landscape only / no auto-rotate I have seen
Possible Duplicate: Tasks should show up only if the user has been assigned it
Possible Duplicate: If string only contains spaces? I do not want to change 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.