I get this error when I try to compare int to int (when comparing string it works)
IEnumerable<Commune> myCommunes = from d in db.Communes
where d.CodePostal == Convert.ToInt32(CodePostal.Text)
select d;
foreach (Commune c in myCommunes)
{
CommunesList.Add(c);
}

Any ideas ?
It looks like
CodePostal.Textis something within your existing context – so all you’ve got to do is extract that from the query:It’s not clear where
CommunesListcomes from – but if it’s empty before this, you could just use: