✅ Better way to set a property using linq?
I have this on a blazor component:
to set a property, I had first set the property on the class and then feed that class to the update method.
I want to streamline the process to something similar to how EF Core sets a property in ExecuteUpdate:
looks like EF Core uses this SetPropertyCall class:
https://github.com/dotnet/efcore/blob/2e9e879746c3a75ad71b1c3732469c25f01bb8c7/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs#L3338
https://learn.microsoft.com/en-us/dotnet/api/microsoft.entityframeworkcore.query.setpropertycalls-1.setproperty?view=efcore-8.0
When I inspected the class on github, I couldn't find anything substantive that I could parse.
The best I could do is this:
SetPropertyCalls.SetProperty Method (Microsoft.EntityFrameworkCore....
Specifies a property and corresponding value it should be updated to in ExecuteUpdate method.
GitHub
efcore/src/EFCore/Extensions/EntityFrameworkQueryableExtensions.cs ...
EF Core is a modern object-database mapper for .NET. It supports LINQ queries, change tracking, updates, and schema migrations. - dotnet/efcore
4 Replies
Why don't you use two way binding?
I'm looping through values witha foreach loop, IIRC you can't bind those
I'll have to try using a for loop instead now that you mention that.
You can, but you need to capture the variable in the loop.
thats awesome, thanks!