Updating fields

Posted by / 25-Oct-2016 07:53

Updating fields

This is when I receive an error if I don't specify a value for all the requiered fields, even thoug I set ISModified = false on those properties. Property(e =This seems like a really nice solution - no muss or fuss; you don't have to manually specify properties and it takes into account all of the OPs bullets - is there any reason this does not have more votes?

@parliament I think I must have been asleep when I wrote that. The actual problem is overriding an intended null value.

And more secure (no need to fear about malicious "hidden fields" or things like that)I think you are right, my bad for trying to overlook View Models. I usually go one step further as per Dino Esposito's blog and create Input Models too, a tad belt and braces but it works quite well.

Just means 2 extra models per models - doh ;-)One of the problems with this approach is that you can't mock db. EF has a reasonably good mocking story elsewhere - it's pretty annoying that (so far as I can tell) they don't have one here. I believe there is yet another way to approach this as well.

Model validation is controlled in the Model State, not in the context.

(T is a class generic parameter.) I like one trip to the database.

Depending on your use case, all the above solutions apply.

This is how i usually do it however : For server side code (e.g.

You get only "properties to update" to populate your view (and then to update).

There's still will be the 2 queries for updating (get original update it), but I wouldn't call this a "Con".

updating fields-1updating fields-61updating fields-83

One thought on “updating fields”