I am trying to write a LINQ query against two objects ( SPListItemCollection and List<SPListItem>).
When my query is like the one below it works fine:
var licFirst = from n in navList.Items.Cast<SPListItem>()
from z in licZeroth
where ((SPFieldLookupValueCollection)n["Parent"]).Select(t=>t.LookupId).Contains(z.ID)
select n;
When I add an item to the select:
var licFirst = from n in navList.Items.Cast<SPListItem>()
from z in licZeroth
where ((SPFieldLookupValueCollection)n["Parent"]).Select(t=>t.LookupId).Contains(z.ID)
select n, ParentId = z.ID;
It begins to error out with:
The name ‘z’ does not exist in the
current context
How can I select z.ID?
In your second version, you need to change the syntax a little to get an anonymous type with 2 properties, the
nand theParentID.If this is not what you want, please clarify in the question.