代码之家  ›  专栏  ›  技术社区  ›  msfanboy

将IEnumerable<T>强制转换为ObservableCollection<T>,而不使用构造函数注入IEnumerable<T>

  •  1
  • msfanboy  · 技术社区  · 16 年前

    observeCollection obsCol=新的observeCollection(myIEnumerable);

    脚本:

    var query = from c in customers
                        select new Customer()
                        {
                           Products = from p in products
                                      where p.Id = c.Id
                                      select p
    };
    

    1 回复  |  直到 16 年前
        1
  •  2
  •   SLaks    16 年前

    这样地:

    ObservableCollection obsCol = new ObservableCollection(myIEnumerable.ToList());
    

    请注意 ObservableCollection 实例不会反映对 customers

    编辑 可观测集合 ,这是不可能投给一个。