title: NHibernate - object references an unsaved transient instance - save the transient instance before flushing
body: <p>I'm getting the following error:</p>
  
  <pre><code>object references an unsaved transient instance - save the transient instance before flushing
  </code></pre>
  
  <p>I do <em>not</em> want to save the transient instance. I'm trying to send validation results back to the client:</p>
  
  <pre><code>        if (MyObject.IsValid()) {
              MyObjectRepo.Hydrate(MyObject);
              return Json(MyObject);
          }
          else {                
              Dictionary&lt;string, string&gt; test = new Dictionary&lt;string, string&gt;();
              test.Add("failure", "failure");
              foreach (var a in MyObject.ValidationResults().ToList()) {
                  test.Add(a.PropertyName, a.Message);
              }                
              return Json(test);
  </code></pre>
  
  <p>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!</p>