Closed scott-mac closed 5 months ago
You're right. The name of that method is a bit confusing.
Ideally you'd have the list of columns to exclude from the update at the beginning of the list of arguments, so it would read something like "Update all the properties, excluding 'Prop1', 'Prop2', with the following settings", unfortunately the variable list of params can only be added at the end of the method in C#.
Sorry about the confusion.
I followed this guide: https://github.com/MoonStorm/FastCrud/wiki/Multiple-entity-mappings for excluding columns from my update. Since I have several cases where I want to omit the same columns I created an overloaded method in my data access layer like this:
I would expect from how the methods are named that UpdatePropertiesExcluding would leave all existing property mappings intact with the exception of whatever you pass in, but its the opposite behavior, it keeps the mappings that you pass into the UpdatePropertiesExcluding method and excludes everything else. I tried changing that line to this:
updateMapping.UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = false, excludeColumns);
but that resulted in no properties being omitted from the update
I was able to workaround it by using a different method:
updateMapping.UpdateProperties(prop => prop.IncludeInUpdates(!excludeColumns.Contains(prop.PropertyName)));
but you may want to consider renaming UpdatePropertiesExcluding