private void suppliersList_SelectionChanged(object sender, SelectionChangedEventArgs e)//组合框选项改变。
{
this.supplier = suppliersList.SelectedItem as Supplier;
this.northwindContext.LoadProperty<Supplier>(this.supplier,s=>s.Products);//怎么理解?
this.productsInfo = ((IListSource)supplier.Products).GetList();//怎么理解?
productsList.DataContext = this.productsInfo;
}背景:Supplier是对应数据库表的实体类;怎么理解第二三句话?好像第二句和第三句没有什么关系一样?
{
this.supplier = suppliersList.SelectedItem as Supplier;
this.northwindContext.LoadProperty<Supplier>(this.supplier,s=>s.Products);//怎么理解?
this.productsInfo = ((IListSource)supplier.Products).GetList();//怎么理解?
productsList.DataContext = this.productsInfo;
}背景:Supplier是对应数据库表的实体类;怎么理解第二三句话?好像第二句和第三句没有什么关系一样?
delegate Products MyDelegate(Supplier str);泛型函数,第一个参数是一个对象,第二个是一个委托:
LoadProperty<Supplier>(Supplier supplier,MyDelegate md);
也可以这样写:
LoadProperty<T>(T t, Func<T, Products> fun);((IListSource)supplier.Products).GetList();就是把Products转换为IList类型。
2、 this.northwindContext.LoadProperty<Supplier>(this.supplier,s=>s.Products)这一句能否说的再简单好理解一点?