я хочу с помощью ID удалить информацию которая находится в бд, но почему то не получаются
public void Detele()
{
using(VideoGamesDatabaseContext context = new VideoGamesDatabaseContext())
{
VideoGame d = context.VideoGames.Find();
if(d != null)
{
context.VideoGames.Remove(d);
context.SaveChanges();
}
}
}
Сформируй d с помощью linq:
VideoGame d = context.VideoGames.Where(v => v.Id == _Id).FirstOrDefault();
где _Id - это айдишник елемента, который ты хочешь удалить
public void Detele(Int32 id)
{
using(VideoGamesDatabaseContext context = new VideoGamesDatabaseContext())
{
VideoGame d = context.VideoGames.Find();
if(d != null)
{
Int32 remove = d.Where(x => x.Id == id).FirstOrDefault();
context.VideoGames.Remove(remove);
context.SaveChanges();
}
}
}
Продвижение своими сайтами как стратегия роста и независимости