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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:25:58+00:00 2026-06-08T17:25:58+00:00

Eveytime I think I am getting a handle on this stuff. Full Error: Unable

  • 0

Eveytime I think I am getting a handle on this stuff.

Full Error:

Unable to create a constant value of type ‘Models.staffnames’. Only primitive types (‘such as Int32, String, and Guid’) are supported in this context.

Versions: .Net 4 EF 4

I think it has something to do with DU and db.UserProfiles being Enumerable but when I try to push it back to make everything IQueryable the whole thing blows up. As it stands right now the error occurs when building the supportlist.

It is interesting to note that the only time this problem seems to crop up is when I am working with the Roles provider. Which in the past I just dumped it out into a for loop.

Any help would be appreciated.

Code:

IEnumerable<MembershipUser> du = Roles.GetUsersInRole("Dealer").Select(u => Membership.GetUser(u)).AsEnumerable();
        IQueryable<staffnames> du_up = du.Join(db.UserProfiles.AsEnumerable(), mu => (Guid)mu.ProviderUserKey, up => up.UserID, (mu, up) => new staffnames
        {
            UserId = (Guid)mu.ProviderUserKey,
            FirstName = up.FirstName,
            LastName = up.LastName
        }).AsQueryable();
        List<MemberSupportModel> support = db.Wins_support.Where(s=>s.dealerid == uid && !s.closed).Select(s=> new MemberSupportModel{
             aeramanagerack = s.aeramanagerack,
             amgrname = du_up.Where(a => a.UserId == s.aeramanger).Select(a=>a.FirstName+" "+a.LastName).FirstOrDefault(),
             aeramangerackdate = s.aeramangerackdate,
             atypedesc = _atype.Where(wt => wt.Value == s.atypeid).Select(wt => wt.Description).FirstOrDefault(),
             wtypedesc = _wtype.Where(wt => wt.Value == s.typeid).Select(wt => wt.Description).FirstOrDefault(),
             comment =s.comment,
             dateSubmitted = s.dateSubmitted,
             vdate =s.vdate,
             venuename = s.Venues_Logs.Venue.venueName           
        }).ToList();
  • 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-08T17:26:01+00:00Added an answer on June 8, 2026 at 5:26 pm

    The problem is the line amgrname = du_up.Where(... because du_up is a collection of a non-primitive type in memory, hence the exception. AsQueryable doesn’t help here, in-memory is in-memory, you can’t change that.

    I would try to load the data you need from the DB separately and then merge your du_up collection with the collection of data loaded from the DB:

    // LINQ to Objects in memory
    IEnumerable<MembershipUser> du = Roles.GetUsersInRole("Dealer")
        .Select(u => Membership.GetUser(u));
    
    // LINQ to Objects in memory
    // db.UserProfiles.AsEnumerable() loads whole UserProfiles table from DB
    IEnumerable<staffnames> du_up = du.Join(db.UserProfiles.AsEnumerable(),
        mu => (Guid)mu.ProviderUserKey, up => up.UserID, (mu, up) => new staffnames
        {
            UserId = (Guid)mu.ProviderUserKey,
            FirstName = up.FirstName,
            LastName = up.LastName
        });
    
    // LINQ to Entites = database query
    List<MemberSupportModel> support = db.Wins_support
        .Where(s=>s.dealerid == uid && !s.closed)
        .Select(s=> new // anonymous result object
        {
            aeramanagerack = s.aeramanagerack,
            aeramanger = s.aeramanger, // needed later for the du_up Where clause
            aeramangerackdate = s.aeramangerackdate,
            atypedesc = _atype.Where(wt => wt.Value == s.atypeid)
                              .Select(wt => wt.Description)
                              .FirstOrDefault(),
            wtypedesc = _wtype.Where(wt => wt.Value == s.typeid)
                              .Select(wt => wt.Description)
                              .FirstOrDefault(),
            comment = s.comment,
            dateSubmitted = s.dateSubmitted,
            vdate = s.vdate,
            venuename = s.Venues_Logs.Venue.venueName
        })
        .AsEnumerable() // execute database query
        // now LINQ to Objects in memory again
        // Copy values from anonymous result object and select data from du_up
        .Select(s => new MemberSupportModel
        {
            aeramanagerack = s.aeramanagerack,
            amgrname = du_up.Where(a => a.UserId == s.aeramanger)
                            .Select(a => a.FirstName + " " + a.LastName)
                            .FirstOrDefault(),
            aeramangerackdate = s.aeramangerackdate,
            atypedesc = s.atypedesc,
            wtypedesc = s.wtypedesc,
            comment = s.comment,
            dateSubmitted = s.dateSubmitted,
            vdate = s.vdate,
            venuename = s.venuename
        })
        .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Everytime I run the program, this mysterious error pops up saying that I have
Slowly but surely I think I'm going mad. After getting the solution to my
I'm getting the error below, every once in a while, when I try to
Okay I dont think anyone has covered this yet. I have a div with
I think I might be on the wrong track here so I'm posting this
i think there is some problem with global scope and local scopes in this
I have this nice little snippet i've made for getting browser position: if (!window.position)
everytime my page loads, im supposed to create a datatable (also a jquery plugin)
Everytime I try to create the following table in MySQL command line: CREATE TABLE
Everytime I use MySQL's CREATE TABLE AS SELECT ... all the tables/indexes being selected

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.