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

entity-framework-4, filter, wpf

Solution

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

public ObservableCollection<MasterPartsList> ParentAssemblyBOM
{
    get 
    {
        var enumerable = this._parentAssemblyBOM
                             .Where(parent => parent.isAssy == true);

        return new ObservableCollection<MasterPartsList>(enumerable); 
    }
}

Problem

I'm trying to return entities where the bool "isAssy" is true: ``` public ObservableCollection<MasterPartsList> ParentAssemblyBOM { get {return this._parentAssemblyBOM.Where(parent => parent.isAssy == true); } } ``` but the entire statement is underlined in red stating that I cannot "convert type IEnumerable to ObservableCollection...are you missing a cast?"

Original source

Related problems