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

  • Thread starter Thread starter Néstor Sánchez A.
  • Start date 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.
 
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).
 
Back
Top