Hi I'm now learning about entity framework and still a beginner. Now, I've been having a problem with deleting multiple data in my database. Here is a piece of my database:
Please click to see the image for database
For example i wanted to delete all data that has a brandId of 2. I tried using this code:
int brandId = (from i in context.brands where i.name == name.Text select i.brandId).First();
var bay2 = (from g in context.logoes where brandId == g.brandId select g).FirstOrDefault();
if (bay2 != null)
{
context.logoes.Remove(bay2);
context.SaveChanges();
}
But it only deletes one data, which is logoId 3. It did not delete logoId 4. What am i doing wrong in my query? How to delete all data that has brandId 2 using entity framework?
logousingRemoveRange..