简体   繁体   English

How to write linq query for select ID from list of list?

[英]How to write linq query for select ID from list of list?

How to write linq query for select ID from list of list? I have following List: SearchingDataList,in this list again contains another list that is called SearchDataList and in this list contains an ID field.

How do i Select that particular ID while I select selectedItem from a ListBox?

The structure is like this:

SearchingDataList.SearchDataList.ID
var result = OuterList.Where(t=>t.InnerList.Any(s=>s.Id == yourID));

Your question is not very clear.

This way you get a list of all ids in the the nested list.

searchindDataLists.SelectMany(x => x.searchDataList).Select(x => x.Id)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM