Print Page | Close Window

Validation not happening on unchanged records

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=2840
Printed Date: 13-Apr-2026 at 7:15pm


Topic: Validation not happening on unchanged records
Posted By: mikedfox
Subject: Validation not happening on unchanged records
Date Posted: 21-Jul-2011 at 12:53pm
I'm sure this is by intent, but validation not happening on unchanged records.
 
Thta sounds reasonable, but its causing us a problem. We have an import process that loads data from an external system. It may not find values for all the fields that the verification rules say should have values. The import doesn't use DevForce.
 
The idea is that the data loads in an invalid state, and the first time the record is accessed, the user is forced to fix it. However, if the user brings up a view that contains parents and children, and doesn't "touch" the child that is missing data, the verification won't catch it on a save.
 
We also have an export process that can only run if all the data is there, so when they hit export, I run down the tree and call the VerificationEngine.Execute on each object. The objects that are missing data do not fail verification.
 
Ideas?
 
 
 
 



Replies:
Posted By: DenisK
Date Posted: 22-Jul-2011 at 2:47pm
Hi mikedfox;

Actually as far as I know, validation does happen on an unchanged entity. Please see below for my test.

      var cust = new Customer();
      Assert.IsTrue(cust.EntityAspect.EntityState.IsDetached());
      _em1.AddEntity(cust);
      Assert.IsTrue(cust.EntityAspect.EntityState.IsAdded());
      cust.EntityAspect.AcceptChanges();
      Assert.IsTrue(cust.EntityAspect.EntityState.IsUnchanged());
      var vrc = _em1.VerifierEngine.Execute(cust);
      Assert.IsTrue(vrc.HasErrors);
      Assert.IsTrue(vrc.Errors.Count > 0);

It also works for a detached entity, that is, an entity that has not been added yet to an EntityManager. Maybe if you can tell me what's different between my test and your use case? Also what version are you using?



Print Page | Close Window