private void Button_Click_2(object sender, RoutedEventArgs e) { linqConnection.Clear(); var query = from value in fruitCollection orderby value.Name select value.Name; foreach (var element in query) { CombinedFruitPlanet item = new CombinedFruitPlanet(); item.FruitName = element; linqConnection.Add(item); } }
private void Button_Click_3(object sender, RoutedEventArgs e) { linqConnection.Clear(); var query = (from f in fruitCollection join p in planetCollection on f.color equals p.color select new { fruitName = f.Name, planetName = p.Name }); foreach (var element in query) { CombinedFruitPlanet item = new CombinedFruitPlanet(); item.FruitName = element.fruitName; item.PlanetName = element.planetName; linqConnection.Add(item); } }