Static DataContext
-
Is it a good programming practice to declare a static/shared DataContext? I have declared one static datacontext linq object on page (asp.net) and which can be shared with other sessions also. Does it affect my application's performance or something? Thanks
-
Is it a good programming practice to declare a static/shared DataContext? I have declared one static datacontext linq object on page (asp.net) and which can be shared with other sessions also. Does it affect my application's performance or something? Thanks
It will make your app bug out. The datacontext is like a sandbox where changes are stored untill they are committed to DB. So its not so much of a performance problem as it is a "the app will crash and burn and corrupt your data" problem. Never ever share a datacontext between users/sessions.
-
Is it a good programming practice to declare a static/shared DataContext? I have declared one static datacontext linq object on page (asp.net) and which can be shared with other sessions also. Does it affect my application's performance or something? Thanks
No. See this post: http://blogs.msdn.com/dinesh.kulkarni/archive/2008/04/27/lifetime-of-a-linq-to-sql-datacontext.aspx[^]
'Howard
-
It will make your app bug out. The datacontext is like a sandbox where changes are stored untill they are committed to DB. So its not so much of a performance problem as it is a "the app will crash and burn and corrupt your data" problem. Never ever share a datacontext between users/sessions.
Thanks Roger