Can you explain LINQ In-memory commits and physical commits?

 Posted by ArticlesMaint on 9/29/2009 | Category: LINQ Interview questions | Views: 2962

Entity objects forms the base of LINQ technologies. So when any data is submitted to database it goes through the LINQ objects. Database operations are done through ‘DataContext’ class. As said previously entities form the base of LINQ, so all the data is sent to these entities first and then its routed to the actual physical database. Due to this nature of working database commits is a two step process, the first step is in-memory and final step is physical commits.
In order to do in-memory operation ‘DataContext’ has provided ‘DeleteOnSubmit’ and ‘InsertOnSubmit’ methods. When we call these methods from the ‘DataContext’ class they add and update data in the entity objects memory. Please note these methods do not change / add new data in the actual database.
Once we are done with the in-memory operations and we want to send all the updates to the database for that we need to call ‘SubmitChanges()’ method. This method finally commits data in to the physical database.


So let’s consider a customer table (customerid, customercode and customername) and see how we can do the in-memory and physical commit operations.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response