| Subject: |
LINQ - LoadOptions not working |
| Updated: |
Nov-4-2007 |
| Rating: |
Not Rated |
| By: |
Rocky Moore - Member #: 1 |
| Location: |
Klamath Falls, Oregon USA |
| Website: |
www.RockyMoore.com |
| Category: |
Computers > Programming > Databases |
I did not have time to fully research this and see exactly where the issue is at, but when using the DataContext LoadOptions to force load of records instead of delayed loading, and then adding a record, it seems the LoadOptions get missed up or it is just the DataContext locking its hooks on the object in someway.
Today I tried the above and after the SubmitChanges() on the DataContext, returned the newly added item after disposing of the DataContext. It seems the DataContext was still tied in and I got an error saying it cannot access the DataContext after disposed.
Next step was to requery the same DataContext for the newly added item thinking the LoadOptions would kick in and load it and child classes. I did not check to make sure it loaded the child objects as expected and it may just be tied to the DataContext, but it did not change anything, same error.
What I ened up doing was disposing of the DataContext and then creating a new one with new LoadOptions again, and this time it worked. I may not had to have gone this drastic, but it worked and I did not have time to look into it further.
The result was to dispose and recreate the DataContext after the add. Not sure if this is by design, perhaps a bug in the beta version or maybe there is just something I am missing. All I know at this point is that it worked, so I could move on ;)
[Submit DIGG for this tip]
-----------
Note: Use the tips posted on this site at your own risk.
The tips are posted by the public and as such may or may not be valid.