Print Page | Close Window

Duplicate 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=3509
Printed Date: 13-Apr-2026 at 4:57am


Topic: Duplicate Records
Posted By: Vonzkie
Subject: Duplicate Records
Date Posted: 27-Jun-2012 at 1:37am
Hi,

Do you have a standard way of validating duplicate records based on some unique fields?

Thanks,
Von



Replies:
Posted By: sbelini
Date Posted: 27-Jun-2012 at 8:44am
Von,
 
You will need to query the database to ensure the value is unique. Try the followinging:
 
protected verride VerifierResult VerifyValue(object itemToVerify, object valueToVerify, TriggerContext triggerContext, VerifierContext verifierContext) {
  var mgr = new EntityManager();
  var value = (string)valueToVerify;
  var isUnique = !mgr.GetQuery<myEntityType>().Any(e => e.myProperty == value);
  return new VerifierResult(!isUnique );
}
 
Note that the above is for a synch environment.
Also, you might want to take a look in the http://drc.ideablade.com/xwiki/bin/view/Documentation/validation-create-custom-verifier - DRC  for more details in creating a custom verifier.
 
Regards,
   Silvio.


Posted By: Vonzkie
Date Posted: 28-Jun-2012 at 2:19am
Hi,

Thanks for the info..
Is there a generic way of doing this? It seems that in every entity type that I want to perform such validations, I will create something like this? Is there some centralize solution?

Regards,
Von


Posted By: sbelini
Date Posted: 28-Jun-2012 at 12:23pm
Hi Von,
 
You could create the query dynamically ( http://drc.ideablade.com/xwiki/bin/view/Documentation/dynamic-query-create - http://drc.ideablade.com/xwiki/bin/view/Documentation/dynamic-query-create ) in your custom verifier.
 
Regards,
   Silvio.



Print Page | Close Window