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?