속성 값에 대해 Collection (다른 Collection을 상속받은)에서 검색하고 싶습니다.LINQ -에 포함되어 있습니까?
private ObservableCollection<User> userCollection = someData;
public class User
{
public string Username { get; set; }
public ObservableCollection<Department> Memberships { get; set; }
}
public class Department
{
public string Name { get; set; }
}
//I can't use "Contains", because it requires an object of type "Department", but I don't have the object, just the string "Name" (in this case "MyDepartment")
var result = from usr in userCollection where (usr.Memberships.Contains("MyDepartment")) select usr;
의견이 있으십니까?