Cannot convert type IEnumerable to ObservableCollection…are you missing a cast?

后端 未结 2 1218
余生分开走
余生分开走 2020-12-21 10:58

I\'m trying to return entities where the bool \"isAssy\" is true:

 public ObservableCollection ParentAssemblyBOM
 {
      get {return          


        
2条回答
  •  眼角桃花
    2020-12-21 11:44

    ObservableCollection has an overloaded constructor that accepts an IEnumerable as a parameter. Assuming that your Linq statement returns a collection of MasterPartsList items:

    public ObservableCollection ParentAssemblyBOM
    {
        get 
        {
            var enumerable = this._parentAssemblyBOM
                                 .Where(parent => parent.isAssy == true);
    
            return new ObservableCollection(enumerable); 
        }
    }
    

提交回复
热议问题