I need to filter a list of objects according to whether a specific property (String type) contains the character 'S' (or 'N') in position 19.
I have this in C#:
IQueryable<Tabla5> lstTipoGasto = objServiceClient.ListaTabla5(int.Parse(number)).AsQueryable();
Tabla5 objTipoGasto = new Tabla5();
objTipoGasto.NombreNom5 = "Seleccione..";
objTipoGasto.CodigoNom5 = -1;
objTipoGasto.TextNom5 = "...";
List<Tabla5> lst = lstTipoGasto.ToList();
lst.Add(objTipoGasto);
lstTipoGasto = lst.AsQueryable();
var lista = lstTipoGasto.AsEnumerable().ToList().Where(x => x.AgregaTabl.Contains("S"))
.Select(x => new
{
x.CodigoNom5,
x.NombreNom5,
x.TextNom5,
x.AgregaTabl
}).OrderBy(x => x.CodigoNom5).ToList();
uddlTipoGasto.DataSource = lista;
uddlTipoGasto.DisplayMember = "NombreNom5";
uddlTipoGasto.ValueMember = "CodigoNom5";
uddlTipoGasto.ValueMember = "TextNom5";
I get an exception. Any ideas why?