Has anybody had luck with this?
Please let me know if I understand it correctly, if I have a simple model let's say with:
public string Name { get; set; }
public string Details { get; set; }
public DateTime? Created { get; set; }
and then I perform a:
var myModel = getCurrentModelFromDb(id);
UpdateModel(myModel, "ModelName", new string { "Name", "Details" });
Should this ONLY update the name and detail properties? Because let's say there was a date already from db in 'created', when I do the above it seems to set my created date to 01-01-0001 from the original.
Moreover, when I then try to explicitly exclude this field with:
UpdateModel(myModel, "ModelName",
new string { "Name", "Details" }, new string { "Created" });
It is still being set to 01-01-0001. Is this a bug, or a strange thing I am doing wrong?
What I effectively want to do, is update my model properties for which there are corresponding form fields for, but leave the rest of them alone which were set from the db fetch alone and not set them to null or default, which is what it currently appears to be doing.
I will say though, perhaps the only difference between above and my real-world scenario is I am using updateModel on a list, so I am effectively getting listFromDb(parentId) and then applying updateModel(myList, "ListPrefix") on that which picks up each item by [0], [1] etc... It works, as all the names are updating, but everything else is not.
Update: I've just realised probably 'includeProperties' is to define which properties you wish to include from the form, similar to how the bind works. If this *is* the case, then how can I tell it to only update certain model properties instead?