none
Passing Data Linq objects between threads RRS feed

  • Question

  • Hello,

    This is what's happening with me:

    I have a parent thread that retrieves a queue from the database then passes each queue item to a worker thread.
    This queue has a 1 to many relationship with another table. For instance, ever queue item has many subitems.

    When I attempt to access the children of the queue item, such as: subitem.whatever, the DataReader will has already closed which causes my worker thread to crash.

    I could fix the problem if there's a way to "auto-expand" each queue item and not needing the DataReader in the worker thread.

    Do you guys have any suggestions?

     
    Tuesday, October 27, 2009 7:31 PM

Answers

  • You can eager-load (auto-expand) the queue items using the DataLoadOptions property on the DataContext object.

    [)amien
    • Marked as answer by Achkar Tuesday, October 27, 2009 11:53 PM
    Tuesday, October 27, 2009 9:39 PM
    Moderator