Entity Framework: Get Number of Rows Affected during Insert Update or Delete

Last Reply 13 days ago By Mudassar

Posted 13 days ago

Hi,

Is there any way to get the rows affected as we have in ADO.Net after Insert, Update or Delete operations in Entity Framework?

If yes please tell how?

You are viewing reply posted by: Mudassar 13 days ago.
Posted 13 days ago

Yes. It is possible using the SaveChanges method of the Entity Framework. It returns an Integer value.

using (CustomersEntities entities = new CustomersEntities())
{
      entities.Customers.Add(customer);
      int insertedRecords = entities.SaveChanges();
}

 

I agree, here is the link: https://www.e-iceblue.com/Introduce/spire-office-for-net-free.html