So, if I want to add a new object to my database, I can write this:
public ActionResult Something(SomeObject Object) {
if (ModelState.IsValid()) {
DataContext.SomeObjects.InsertOnSubmit(Object);
DataContext.SubmitChanges();
};
}
But, how does validation get called when I want to update an object? Does UpdateModel<T>
automatically perform the validation or do I have to do something to tell it to or do I have to do something ahead of calling UpdateModel<t>
?
EDIT:
For @SLaks, so do I do something like this:
UpdateModel<SomeObject>(Object);
if (ModelState.IsValid()) {
DataContext.SubmitChanges();
};
Or, if I'm butchering that, please show me the right way.