Wpf 如何将“System.Collections.Generic.List”转换为IEnumerable

Wpf 如何将“System.Collections.Generic.List”转换为IEnumerable,wpf,Wpf,我将此代码用于选择两个字段 public ViewModelList(CRMEntities crm) { var cus = (from c in crm.Customer select new { c.Name, c.Family }); AllCustomer = new ObservableCollection<Custom>(cus.ToList());

我将此代码用于选择两个字段

     public ViewModelList(CRMEntities crm)
    {
       var cus = (from c in crm.Customer
                  select new 
                  { c.Name, c.Family });
        AllCustomer = new ObservableCollection<Custom>(cus.ToList());
     }
     public ObservableCollection<Custom> AllCustomer
    {
        get;
        set;
    }


    }

    public class Custom
   {
     public  string Name{get;set;}
    public string Family { get; set; }

   }
,但给出了以下错误


无法从“System.Collections.Generic.List”转换为“System.Collections.Generic.List”

在ObservableCollection中,您指定的元素类型为自定义。 执行选择时,您正在创建匿名类型。使用新的{…}将创建一个匿名类型

你可能想做的是

select new Custom { Name = c.Name, Family = c.Family };