I'm getting the following error:
object references an unsaved transient instance - save the transient instance before flushing
I do not want to save the transient instance. I'm trying to send validation results back to the client:
if (MyObject.IsValid()) {
MyObjectRepo.Hydrate(MyObject);
return Json(MyObject);
}
else {
Dictionary<string, string> test = new Dictionary<string, string>();
test.Add("failure", "failure");
foreach (var a in MyObject.ValidationResults().ToList()) {
test.Add(a.PropertyName, a.Message);
}
return Json(test);
If the object is not valid and I don't have the test dictionary and foreach statement (for example just sending back, a failure string), it'll work fine. All other questions I've found on this relate to failures saving the object ... the object is not valid and I do not want to save it, just send down the results of the failed validation. Thanks!