LINQ to SQL, over ASP.NET, DataContext.GetTable trouble

  • Thread starter Néstor Sánchez A.
  • Start date
N

Néstor Sánchez A.

Hi,

Working with LINQ to SQL over an ASP.NET application (VS2008, .NET 3.5)
while calling
"MyDataContextInstance.GetTable<MyTable>()"
it produces sometimes the following exception:
"an item with the same key has already been added"

I think is some trouble about concurrency or async calls
(MyDataContextInstance is an static variable).
Could it be a problem related to ASP.NET application lifecycle management?
or...
a LINQ to SQL (DataContext) bug not supporting concurrency?

Thanks in advance for your time.


Néstor Sánchez A.
 
M

Miha Markic

DataContext isn't thread safe:
"Any public static (Shared in Visual Basic) members of this type are thread
safe. Any instance members are not guaranteed to be thread safe."
(from the docs).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top