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. Linq Deferred Execution vs Fetching data on a separate thread

Linq Deferred Execution vs Fetching data on a separate thread

Scheduled Pinned Locked Moved LINQ
csharpsharepointvisual-studiolinqdesign
4 Posts 2 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.
  • F Offline
    F Offline
    francoisdotnet
    wrote on last edited by
    #1

    Thus far (before 3.5) I have been using a separate thread when fetching data from a data source. Especially if (a) it is a substantial amount of data or (b) the SP tends to take a while due to data-processing. This keeps the UI snappy until the data arrives! But now with LinqToSQL and deferred execution, the data is fetched at the last possible moment. Does one abandon either threading or LinqToSQL, or is there a way to integrate them, and if so what would be the best way? I'd really like to hear everyone's thoughts and ideas!

    F G 2 Replies Last reply
    0
    • F francoisdotnet

      Thus far (before 3.5) I have been using a separate thread when fetching data from a data source. Especially if (a) it is a substantial amount of data or (b) the SP tends to take a while due to data-processing. This keeps the UI snappy until the data arrives! But now with LinqToSQL and deferred execution, the data is fetched at the last possible moment. Does one abandon either threading or LinqToSQL, or is there a way to integrate them, and if so what would be the best way? I'd really like to hear everyone's thoughts and ideas!

      F Offline
      F Offline
      francoisdotnet
      wrote on last edited by
      #2

      http://channel9.msdn.com/forums/Coffeehouse/402104-DataContext-Linq-to-SQL-and-Win32-best-practices/[^] The above discussion seems to in the direction of: don't use LinqToSQL for "bigger" production and/or enterprise applications as it is not mature enough yet?

      1 Reply Last reply
      0
      • F francoisdotnet

        Thus far (before 3.5) I have been using a separate thread when fetching data from a data source. Especially if (a) it is a substantial amount of data or (b) the SP tends to take a while due to data-processing. This keeps the UI snappy until the data arrives! But now with LinqToSQL and deferred execution, the data is fetched at the last possible moment. Does one abandon either threading or LinqToSQL, or is there a way to integrate them, and if so what would be the best way? I'd really like to hear everyone's thoughts and ideas!

        G Offline
        G Offline
        Gideon Engelberth
        wrote on last edited by
        #3

        Deferred execution does not solve the problem that the separate thread solves. If you run a LINQ query on the main thread, the entire query operation will take place on that thread (unless LinqToSql does some funny things behind the scenes). It may just happen at a different point in the code. I have not used LinqToSQL myself, but from what I understand, the query will need to translate to SQL at some point and then you are basically back to where you started before LINQ. Probably you will need to integrate the two. I would keep the threading just the way it is and replace the SQL calls/queries with the appropriate LINQ.

        F 1 Reply Last reply
        0
        • G Gideon Engelberth

          Deferred execution does not solve the problem that the separate thread solves. If you run a LINQ query on the main thread, the entire query operation will take place on that thread (unless LinqToSql does some funny things behind the scenes). It may just happen at a different point in the code. I have not used LinqToSQL myself, but from what I understand, the query will need to translate to SQL at some point and then you are basically back to where you started before LINQ. Probably you will need to integrate the two. I would keep the threading just the way it is and replace the SQL calls/queries with the appropriate LINQ.

          F Offline
          F Offline
          francoisdotnet
          wrote on last edited by
          #4

          Thanks for your input Dideon, I agree with you deferred execution doesn't solve the problem threading solves. The problem it creates is that even thought the LINQ query is in the background thread it doesn't execute the call to the database until much later, that is until back in the UI thread (most of the time). As the other article I posted suggests, there are ways to "force" LINQ to execute in the background thread but I don't think that is ideal as it kind of defeats some of the porpose of LINQ. For now I have decided to stay away from LinqToSql for bigger projects. Still using and loving Linq in general though ;)

          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