c# - create some sort of loop inside linq query -
i have method want use filter listview. creating listview dynamically therfore don't know number of colums in advance. lstcurrentdynamicitems class 1 property , property named c , type object[]. created class in order hold objects of listview. if have same listview have no problem building following method. how implement following method?
public void filterlistview(string[] columnscontains) { // lstcurrentdynamicitems list of objects // columnscontains want filter. var qr = in lstcurrentdynamicitems a.c[0].tostring().contains(columnscontains[0]) && a.c[1].tostring().contains(columnscontains[1]) && a.c[2].tostring().contains(columnscontains[2]) && // ... // ... // ... a.c[columnscontains.length].tostring().contains(columnscontains[columnscontains.length]) select a; listview.datacontext = qr; }
something should work:
var qr = in lstcurrentdynamicitems enumerable.range(0,columnscontains.length) .all(i => a.c[i].tostring().contains(columnscontains[i])) select a;
Comments
Post a Comment