New Posts New Posts RSS Feed: Validation not happening on unchanged records
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Validation not happening on unchanged records

 Post Reply Post Reply
Author
mikedfox View Drop Down
Newbie
Newbie


Joined: 29-Apr-2010
Posts: 21
Post Options Post Options   Quote mikedfox Quote  Post ReplyReply Direct Link To This Post Topic: Validation not happening on unchanged records
    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?
 
 
 
 
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post 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?
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down