C# Entity Framework Multiple Row Delete

c-sharp

C# Entity Framework

the .NET platform, you’ve heard about the Entity Framework technology that simplifies operations on SQL databases. If you haven’t heard, I suggest you investigate. Now 6.I’m interested in version x. As of May 27, 2015, I wrote the article in the Entity Framework 7 Beta has been published. The beta version is 6 to be free from errors.X is also worth going on. If you are new to EF 6.be careful to start with the X version,now on the internet 5.x and 4.x-related cholar, but I say it is useful to start with new technology.

C# Multiple Row Delete

On the subject of the article;

In this article, I’ll talk about deleting multiple lines with the Entity Framework. You can also delete a batch of records. First, I find it useful to look at a single record deletion.

 

 

 

In the code here, we find the first record with the value of classidsof 3 and delete the record with the Remove method from our dB.So we’re deleting a student with classid 3. But I share his code as well what should I do if I want to delete all students with class id 3.

 

The firstordefault method is a method of bringing single record.
Where it finds all the results.To delete multiple records, we need to bring all the records to be deleted.
Then we delete multiple records with RemoveRange method instead of remove.