Imagine this model:
public class User
{
public int Id { get; set; }
public required FullName FullName { get; set; }
}
[Owned]
public class FullName
{
public required FirstName { get; set; }
public required LastName { get; set; }
}
Inserting a User with by assigning a FullName object to the FullName property works:
db.Add(new User
{
FullName = someFullNameObj,
});
db.SaveChanges();
But doing the same with ExecuteUpdate doesn't work:
db.Users.Where(u => u.Id == userId)
.ExecuteUpdate(b => b
.SetProperty(u => u.FullName, someFullNameObj)
);
It throws an exception along these lines:
The LINQ expression ... could not be translated. The following lambda argument to 'SetProperty' does not represent a valid property to be set: 'u => u.FullName'.
This is an unexpected asymmetry between how insert and update work, I think most people would intuitively expect the ExecuteUpdate example to work just fine, it's a bit surprising, a weird limitation.
Let me know if there's an existing issue for this.
Imagine this model:
Inserting a
Userwith by assigning aFullNameobject to theFullNameproperty works:But doing the same with
ExecuteUpdatedoesn't work:It throws an exception along these lines:
This is an unexpected asymmetry between how insert and update work, I think most people would intuitively expect the
ExecuteUpdateexample to work just fine, it's a bit surprising, a weird limitation.Let me know if there's an existing issue for this.