Reputation: 69
I have a method that allows me to create an agent list. This list of agents contains "Nom", "Prenom", "Matricule", "Mail".
I use.distinct() to sort them, but this only takes into account "Nom", "Prenom", "Matricule". This does not check if the emails are different. How do I proceed?
The creation of my agent list:
private ObservableCollection<AgentMailModel> _Agents;
public ObservableCollection<AgentMailModel> Agents
{
get
{
return _Agents;
}
set
{
if (value != _Agents)
{
_Agents = value;
RaisePropertyChanged("Agents");
}
}
}
foreach (Destinataire dst in (await _dataService.GetDestinatairesAsync()))
_TmpAgents.Add(new AgentMailModel() { Matricule = dst.Matricule, Nom = dst.Nom, Prenom = dst.Prenom, Mail = dst.Mail });
foreach (AgentModel ag in (await _dataService.GetAgentsContratsAsync()))
_TmpAgents.Add(new AgentMailModel() { Matricule = ag.Matricule, Nom = ag.Nom, Prenom = ag.Prenom, Mail = ag.Mail });
Agents = new ObservableCollection<AgentMailModel(_TmpAgents.Distinct());
My list in WPF :
My database :
As you can see :
It displays "carré" (cause "Nom" is different, It also works with a different "Prenom" or "Matricule) and only one "carre" (without "é").
Distinct() doesn't work with my Mails. Any tips ?
Upvotes: 0
Views: 69