コレクション(別のコレクションを継承する)でプロパティ値を検索したいのですが。
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;
何か提案はありますか?