.net - Linq query to filter a list of strings in Observable collection -


from observable collection want filter items names aaa,bbb,ccc,ddd,eee. how this?

public class item { public string itemname {get; set;} public int itemnumber {get; set;} }  public observablecollection<item> _items;  public list<string> searchitems = new list<string>(5); searchitems.add("aaa"); searchitems.add("bbb"); searchitems.add("ccc"); searchitems.add("ddd"); searchitems.add("eee"); 

i tried bit in linq.. dont know how list..

var filtereditems = item in _items                     _items.any(x => x.itemname == "aaa")                     select x; 

you can use contains;

var filtereditems = item in _items                     _items.any(x => searchitems.contains(x.itemname))                     /*select x;*/                     select item; 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -