Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. LINQ
  4. Static DataContext

Static DataContext

Scheduled Pinned Locked Moved LINQ
csharpasp-netlinqperformancequestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    divyesh1432
    wrote on last edited by
    #1

    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

    R H 2 Replies Last reply
    0
    • D divyesh1432

      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

      R Offline
      R Offline
      Roger Alsing 0
      wrote on last edited by
      #2

      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.

      My Blog

      D 1 Reply Last reply
      0
      • D divyesh1432

        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

        H Offline
        H Offline
        Howard Richards
        wrote on last edited by
        #3

        No. See this post: http://blogs.msdn.com/dinesh.kulkarni/archive/2008/04/27/lifetime-of-a-linq-to-sql-datacontext.aspx[^]

        'Howard

        1 Reply Last reply
        0
        • R Roger Alsing 0

          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.

          My Blog

          D Offline
          D Offline
          divyesh1432
          wrote on last edited by
          #4

          Thanks Roger

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups