Last post Nov 18, 2014 10:03 AM by nvielbig
Nov 18, 2014 09:26 AM|nvielbig|LINK
All, I have a list of parents, which contains a list of children. When attempting to filter the Parents, and then Filter the returned parents' children, I am encountering some issues.
My query is below. Basically, I want to select the parent who's Kit ID matches a local variable's value, Then I'd like to select the warehouse from a child of that parent who's Fixture ID matches a local variable.
That came out in quite a confusing way, but hopefully you can connect the dots... let me know if you need more clarification.
' bomInfoList is a List of "Parent" objects, each of which can contain one to many children (Lines)_bom = bomInfoList.FirstOrDefault(From bom In bomInfoList
Where (bom.KitId = KitHID) _
From line In bom.Lines
Where line.ComponentId = FixtureID
)' Here is where I attempt to set that value
ThisSheet.Cells("F" & Count + 1).Value = _bom.Lines.FirstOrDefault.Warehouse
I've tried many ways, but I get the same exception every time ... something along the lines of
"Cannot convert object of type WhereListIterator`1 to type of System.Func`2".
Nov 18, 2014 09:51 AM|sam_xiii|LINK
I cannot test, bu try this way
var warehouse = (from b in bomInfoList
where b.KitId == KitHID
from l in b.lines
where l.ComponentId == FixtureID
http://www.sambeauvois.be | @sambeauvois
Nov 18, 2014 10:03 AM|nvielbig|LINK
Hi Sam ...
Well, the compiler is able to get past this line, and all looks like it's working! Thanks so much. P.S I did post VB code (I prefer C# ;)), So I did have to change == to =, but besides that it ran flawlessly