.net - C# Expression List contains -


i sorry description. english not good. let me try describe again.

say have lamdaexpression parameter method named findproducts. need parse parameter in findproducts method, issue encountered not value list of parameter when parameter below code(listn.contains()):

var sfilter = new list<string>(){"afilter", "bfilter"}; myobj.findproducts(s => sfilter.contains(s.name)); --- here parameter expression 

my questions how values in list sfilter(afilter , bfilter) in method findproducts?

all want parse expression, convert sql script. in case, want this: findproducts(s=>filterlist.constains(s)), here try parse s column name, filterlist should in clause in sql. make sql this: select * table s in ('a', 'b') expression

try (if interpreting question correctly):

var productlist = new list<string>() {"a", "b", "c", "d", "e"}; var filterlist  = new list<string>() {"a", "b"};   var foundlist = findproducts(productlist, s => filterlist.contains(s));  list<string> findproducts(list<string> products, func<string,bool> filter) {     return products.where(s => filter(s)).tolist(); } 

Comments