I have the following table:
Nombre-----Lista1-----Lista2-----Lista3-----Lista5
Casa 1 1 0 1
Arbol 1 0 0 0
Bola 0 1 1 1
How can I search by column name, for example if I try to search all list elements with 1 using EF
it would be like this:
var lista=ctx.Tabla.Where(x=>x.Lista1==1)
ToList();
EXIT
House
Tree
How would I search for all the elements of X list where it is 1, for example:
var NombreLista="Nombre columna a buscar";
var lista=ctx.Tabla.Where(x=>x.+NombreLista+==1) //AQUI NO PUEDO HACER ESTO
ToList();
How would I search by column and not by value equal to column?
You can do it using System.Linq.Dynamic.Core package https://www.nuget.org/packages/System.Linq.Dynamic.Core/
This package allows you to perform dynamic filters (among other things) by passing a string predicate to the Where() extender method.