Wybieranie jednego ID z tabeli w metodzie

0

Witam
Jak napisać zapytanie za pomocą LINQ w metodzie aby wybierało mi tylko jedno ID.
Kolumny w tabeli to mam ID i nazwe produktu.

public ActionResult CreateRecipe(int idProduct)
        {
            FrykasDbContext frykasDb = new FrykasDbContext();
            RecipesVM recipesvm = new RecipesVM();          
            recipesvm.Id = idProduct;           
            recipesvm.RecipeVM = new List<Recipes>();
            var recipelist = frykasDb.Recipes.ToList();
            foreach(var item in recipelist)
            {
                Recipes objrecvm = new Recipes();
                objrecvm.IdRecipe = item.IdRecipe;
                objrecvm.Quantity = item.Quantity;
                recipesvm.RecipeVM.Add(objrecvm);
            }

            recipesvm.IngredientsVM = new List<Ingredients>();
            var ingredientslist = frykasDb.Ingredients.ToList();
            foreach(var item in ingredientslist)
            {
                Ingredients objingvm = new Ingredients();
                objingvm.Id = item.Id;
                objingvm.Name = item.Name;
                recipesvm.IngredientsVM.Add(objingvm);
            }
            
            return View(recipesvm);
        }
0

Jeśli tylko jedno, to które? Na przykład można tak:
https://forums.asp.net/t/1203694.aspx?Linq+to+SQL+Select+top+1+[]

0

Nie wiem czy dobrze zrozumiałem, nie mogę przetworzyć tego kodu
zobacz to: https://www.plukasiewicz.net/Artykuly/Single_SingleOrDefault_First_FirstOrDefault

1 użytkowników online, w tym zalogowanych: 0, gości: 1