Sorry if this is a duplicate. Please point me to the appropriate question, if so, but I could not find exactly what I am looking for.
Therefore, I use datacontext Linq to SQL to track and store entities in an ASP.NET web application. This intranet app does not have tons of users at a time. Right now I cam keep the datacontext in session state, which makes me feel dirty! I seem to need a context that is always present because I need to keep track of changes for objects that are changing. All of our screens have a Save button, which then calls the SubmitChanges () method in the DataContext and stores all pending changes in memory.
Should I store a DataContext? Should I get rid of it at the end of each request, and then somehow recreate it and get the pending changes? If I have to recreate it every time, I donβt understand how the context could know what changed without a ton of redundant database hits on each request.
source share