public UsersViewModel() { this.ListF = new ObservableCollection <FiliereCount>(); var filCount = from etudiant in cl.etudiants join filiere in cl.filieres on etudiant.id_filiere equals filiere.id_filiere group new { etudiant, filiere } by filiere.nom_filiere into grouping select new { grouping.Key, nbEtudiant = grouping.Count() }; foreach (var gr in filCount) { ListF.Add(new FiliereCount { Filiere = gr.Key, nbEtudiant = gr.nbEtudiant }); } }