c# - Linq query change from List<string> to List<T> where clause -
i have linq query works when had list of single value change having list has several properties need change clause
so works:
list<string> etchlist = new list<string>(); etchlist.add("24"); var etchvect = (from vio in addplas etchlist.any(v => vio.key.formatted.equals(v)) let firstordefault = vio.shapes.firstordefault() firstordefault != null select new { etchvectors = firstordefault.formatted }).tolist();
however have new hard coded list (which represent incoming data:
list<excelviolations> excelviolations = new list<excelviolations>(); excelviolations.add(new excelviolations { vioid = 24, ruletype = "spacing", viotype = "line-line", xcoordinate = 6132, ycoordinate = 10031.46 });
so new linq query looks this, not work addplas list , using other list of excelviolations, wish have on each 1 of properties in excelviolations list
var etchvect = (from vio in addplas excelviolations.any(vioid => vio.key.formatted.equals(vioid)) let firstordefault = vio.shapes.firstordefault() select new { etchvectors = firstordefault.formatted }).tolist();
now, since list within list, add in each of properties example:
excelviolations.vioid.any(vioid => vio.key.formatted.equals(vioid))
however not possible, see i'm trying access property of vioid in excelviolations , match key in vio list
just change line
where excelviolations.any(vioid => vio.key.formatted.equals(vioid))
to
where excelviolations.any(excelvio => vio.key.formatted.equals(excelvio.vioid))
then thought works
Comments
Post a Comment