Description
I was expecting to find find an existing issue for this but I couldn't (if there is one please let me know):
ExecuteUpdate
currently only accepts an expression, this means you cannot dynamically build an update query, and do things like this:
query.ExecuteUpdate(b =>
{
if (someCondition)
b.SetProperty(e => e.Something, "Something");
else
b.SetProperty(e => e.Foo, "Foo");
b.SetProperty(e => e.Bar, "Bar")
});
But this would be extremely useful and is sometimes very much needed.
IIRC I believe somebody brought this up somewhere in one of the associated issues (probably in #795), but I don't remember what the response from the EF team was. It kind of seems surprising that this isn't already supported (there are Stack Overflow questions about it, for example). The expressions passed to .SetProperty()
are all that matters anyway, so it seems like the ExecuteUpdate
parameter being an expression is unnecessary, it could've just been an Action
, but definitely correct me if I'm wrong. Thanks.
Update: Found the comment that had mentioned this: #795 (comment) (see surrounding conversation) — Shay then said this:
Ah, could be... @smitpatel will determine whether this is feasible and reasonable to implement.
I don't think there were any updates afterwards.