//filtrowanie listy przepisow wedlug wyszukiwanej nazwy private void Search() { using (var contex = new CookingBookEntities1()) { RecipeList = new ObservableCollection<Recipe>(contex.Recipes.Where(x => x.Title.ToUpper().Contains(SearchTxt.ToUpper()))); } }
//wyswietlanie listy przepisow spelniajacych kryteria wyszukiwania private void Search() { using (var contex = new CookingBookEntities1()) { if (SelectedTitle) { RecipeList = new ObservableCollection <Recipe>(contex.Recipes.Where(x => x.Title.ToUpper().Contains(SearchTxt.ToUpper()))); } else if (SelectedAuthor) { RecipeList = new ObservableCollection <Recipe>(contex.Recipes.Where(x => x.Author.Name.ToUpper().Contains(SearchTxt.ToUpper()))); } else if (SelectedIngredient) { RecipeList = new ObservableCollection <Recipe>(contex.Recipes.Where(x => x.Ingredients.Any(v => v.Name.ToUpper().Contains(SearchTxt.ToUpper())))); } } }