0

私は以下のようなクラス構造を持っています。

ObservableCollection<Group> deviceCollection = new ObservableCollection<Group>();
public class Group 
{ 
    public string Name { get; set; }       
    public List<TargetSelectionStructure> TargetCollection { get; set; }
}
public class TargetSelectionStructure
{
    public string ItemId { get; set; }
    public string Name { get; set; }
    public bool IsGroup { get; set; }
}

監視可能なコレクション オブジェクト deviceCollection から。IsGroup プロパティと一致するコレクションを false として取得する必要があります。だから私は次のように書いています

var currentStruct = deviceCollection.Where(d => d.TargetCollection.Any(t => t.IsGroup == false));

現在、 currentStruct には基本的にコレクションが含まれている必要がありますList<TargetSelectionStructure>。currentStruct を の型にキャストできませんList<TargetSelectionStructure>
どうすればこれを解決できますか?

4

1 に答える 1