You can solve your problem using one CustomValidation, and i think its the best way since you may or may not have all records loaded on the client side, and in the case you dont have all employes loaded you need to go to the DB to check if there is one with the title beeing inputed...
Basically it would go like this:
First Create the Class that's going to be responsible for the Employees Validation
public class EmployeeValidationRules
{
}
then the method that will actually do the Validation:
public static ValidationResult ValidateTitle(string title, ValidationContext context)
{
AdventureWorks_DataEntities objectContext = new AdventureWorks_DataEntities();
Employee employee = context.ObjectInstance as Employee ;
if (objectContext.Emplyees.Any(e => e.Title == employee.Title))
{
return new ValidationResult("Title Allready Exists", new string[] { "Title" });
}
return ValidationResult.Success;
}
On the metadata generated by your domainservices in the Employee class search for the title property and you have to add this tag:
[CustomValidation(typeof(EmployeeValidationRules), "ValidateTitle")]
public string Title{ get; set; }
Note: All this must be done on the server side...
You can find more information about WCF Validations here:
http://www.silverlightshow.net/items/WCF-RIA-Services-Part-6-Validating-Data.aspx
Here is another very well written article by Jeff Handley on WCF validations:
http://jeffhandley.com/archive/2010/09/25/RiaServicesCustomValidationMethods.aspx