❔ EntityFramework does not track changes for the select projection
Hey, With Select (), I only extracted the data I needed, which I want to update later. However, after SaveChanges () is executed, the value in DB does not change.
On the other hand, with such a code, the change already appears correctly
Can I somehow make changes to the truncated retrieved data like in the first code?
2 Replies
Well, yeah
After
.Select()
it's a different object
What if you .Select(p => p.Price)
?
Or .Select(p => new { Cost = p.Price, Text = p.Name }
?
EF has no way to track those
If you want to edit the entity, you need it whole
Or you can use .ExecuteUpdateAsync()
that was added in EF Core 7
.Select()
is used when you only intend to display the values, not change themWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.