Attendre reponse WCF Ria Services
Bonjour,
dans mon ViewModel, j'ai une propriété Libelle_Compte avec comme DataAnnotation
Code:
[CustomValidation(typeof(MyValidation), "Libelle_Compte_Is_Unique", ErrorMessage = "Ce nom de compte est déjà utilisé, veuillez en choisir un autre")]
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
public static ValidationResult Libelle_Compte_Is_Unique(string libelleATester)
{
ServiceReferentiel referentiel = new ServiceReferentiel();
bool is_Non_Unique = true;
referentiel.Load<Compte>(referentiel.GetCompteQuery(),
loadOp =>
{
if (loadOp.HasError)
MessageBox.Show(loadOp.Error.Message);
else
{
is_Non_Unique = referentiel.Comptes.Any(cpt => cpt.Libelle_Compte == libelleATester);
MessageBox.Show(referentiel.Comptes.Count.ToString());
}
}
, null);
MessageBox.Show("ok");
if (is_Non_Unique)
return new ValidationResult("Veuillez choisir un autre nom pour votre compte");
else
return ValidationResult.Success;
} |
Mon souci est is_Non_Unique est tjrs à true dans le if car le if est exécuté avant que la loadoperation soit terminée. Comment faire pour lui dire d'attendre ?
merci