我有以下嵌套結構。
List<SomeType>其中有另一個串列,List<AnotherType>其中內部有一個array of strings users.
public class SomeType
{
public string EmployeeNo { get; set; }
public List<AnotherType> AnotherType { get; set; }
}
public class AnotherType
{
public string UserName { get; set; }
public string[] Users { get; set; }
}
假設我想在 string 陣列中搜索一個值Users。我怎樣才能做到這一點。
uj5u.com熱心網友回復:
你想做這樣的事情嗎?
var query = SomeTypeList
.Where(sometype => sometype.AnotherType.Any(
anothertype => anothertype.Users.Any(
user => user.Contains("user to search for"))))
看起來像重復:stackoverflow: C# LINQ Filter deep nested list
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/438268.html
上一篇:在c#中加入多個物件串列
