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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:13:02+00:00 2026-06-13T19:13:02+00:00

LINQ to Entities allows this: context.User.Select(u => new Person { Name = u.Name, Parent

  • 0

LINQ to Entities allows this:

context.User.Select(u => new Person
{
    Name = u.Name,
    Parent = u.Parent.Name
});

I need only two properties of a big User table and I get them using the Select method to create a Person object so I can do some processing with it. The thing is that I do this a lot (like twice a second) and it hurts the GC.

So I decided to pool the Person objects but I have no idea how to update an existing object using LINQ to Entities. I can get it as an anonymous method like above and then assign its properties to the depooled object I guess, then I can return the depooled instance, this would at least make the anonymous instance go away in a lower generation of GC but…

I’d really prefer something like this:

context.User.Select(u => People.Take(u.Name, u.Parent.Name))

Which throws a NotSupportedException.

  • Can I use Entity Framework to update the values of an existing object?
  • If so, how?
  • If not, what alternatives do I have?
  • 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-13T19:13:03+00:00Added an answer on June 13, 2026 at 7:13 pm

    Can I use Entity Framework to update the values of an existing object?

    No – the Select method is used for projection not updating – what your doing is the correct approach. Alternatively you may find it more efficient to change your Person class to a struct as it consumes less memory.

    I think you need to elaborate a little more on “It hurts the GC“.

    Update

    It appears Linq to Entities does not support projecting onto struct‘s (seems like a limitation to me) – best possible approach then would be to just project onto an anonymous type & then you can map your results onto your Person class using your pooling mechanism e.g.

    var users = (from u in context.User
                select new {
                    Name = u.Name,
                    Parent = u.Parent.Name
                }).ToList().Select(u => People.Take(u.Name, u.Parent));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using LINQ-to-Entities and need to populate a ListView using a select statement
Why in Linq to Entities do I need to specify relationships with Include(string)? Linq
I'm new to linq and linq to entities so I might have gone wrong
I'm using LINQ-to-Entities. Using the following query: var x = from u in context.Users
Using LINQ to Entities, I need to get records from a PersonTable WHERE Age
I am new to Linq to Entities, and have no idea how to make
I was looking for linq to entities extension which allows to add OPTION(MAXDOP x)
I am trying to select some records using LINQ for Entities (EF4 Code First).
I have a LINQ to Entities statement that joins two models on an AlphaGroupID,
Using LINQ to Entities, how can I determine if any item from a List

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.