ContentControl control; string selectedItem = string.Empty; int selectedCategory = 0; string selectedPrice = string.Empty; // Controls for Category ComboBox control = categoryComboBox.SelectedItem as ContentControl; if (control != null) { selectedItem = (string)control.Content; } // Controls for Price ComboBox control = priceComboBox.SelectedItem as ContentControl; if (control != null) { selectedPrice = (string)control.Content; } #region if (selectedItem == "Electronics and Computers") // Entertainment Option { selectedCategory = 1; } else if (selectedItem == "TV and Video") // Entertainment Option { selectedCategory = 2; } else if (selectedItem == "Home Audio and Theater") // Entertainment Option { selectedCategory = 3; } else if (selectedItem == "Camera, Photo and Video") // Entertainment Option { selectedCategory = 4; } else if (selectedItem == "Cell Phones and Accessories") // Entertainment Option { selectedCategory = 5; } else if (selectedItem == "Video Games") // Entertainment Option { selectedCategory = 6; } else if (selectedItem == "MP3 Players and Portable Speakers") // Entertainment Option { selectedCategory = 7; } else if (selectedItem == "Car Electronics and GPS") // Entertainment Option { selectedCategory = 8; } else if (selectedItem == "Musical Instruments") // Entertainment Option { selectedCategory = 9; } else if (selectedItem == "Electronics Accessories") // Entertainment Option { selectedCategory = 10; } else if (selectedItem == "Laptops and Tablets") // Entertainment Option { selectedCategory = 11; } else if (selectedItem == "Desktops & Monitors") // Entertainment Option { selectedCategory = 12; } else if (selectedItem == "Computer Accessories and Peripherals") // Entertainment Option { selectedCategory = 13; } else if (selectedItem == "Computer Parts and Components") // Entertainment Option { selectedCategory = 14; } else if (selectedItem == "Software") // Entertainment Option { selectedCategory = 15; } else if (selectedItem == "PC Games") // Entertainment Option { selectedCategory = 16; } else if (selectedItem == "Musical Instruments") // Entertainment Option { selectedCategory = 9; } #endregion var query = context.CreateQuery<Customer>("GetProducts").AddQueryOption("selectedCategory", selectedCategory); // .AddQueryOption("selectedPrice", selectedPrice); productsViewSource.Source = query.Expand("ProductOptions"); productsDataGrid.SetBinding(DataGrid.ItemsSourceProperty, "ProductOptions");
[WebGet] public IQueryable<Product> GetProducts(int selectedCategory) { if (selectedCategory > 0) { iShopEntities context = this.CurrentDataSource; var products = from product in context.Products // .Include("ProductOptions") where product.CategoryID == selectedCategory // && product.Price == selectedPrice select product; return products; } else { throw new DataServiceException("Blah"); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)