public static List<TipoPrimarioHistologia> CodigoSitioPrimario(string searchText, int maxResults, int code) { Repositorio repo = new Repositorio(); List<TipoPrimarioHistologia> names = new List<TipoPrimarioHistologia>(); DataSet sitiosDset = repo.GetSitiosPrimarios(); foreach (DataRow row in sitiosDset.Tables[0].Rows) names.Add(new TipoPrimarioHistologia { id = row.ItemArray[2].ToString(), code = row.ItemArray[0].ToString(), desc = row.ItemArray[1].ToString() }); if (code == 1) { var result = from n in names where n.code.ToUpper().Contains(searchText.ToUpper()) orderby n.code select n; return result.Take(maxResults).ToList(); } else { var result = from n in names where RemoveDiacritics(n.desc).ToUpper().Contains(searchText.ToUpper()) orderby n.desc select n; return result.Take(maxResults).ToList(); } }