The problem is not about the DataContext itself, it about it's caches.

Each cache shared among threads MUST be thread safe.

Probably, Linq to SQL's DataContext doesn't use so many caches as DbLinq
does.


If we could remove caches, we have no problem. Otherwise a problem might be.


How could I inject a thread safe QueryCache implementation? Is it matter of
ObjectBuilder?


Giacomo

On Thu, Apr 23, 2009 at 10:34 AM, Pascal Craponne <[email protected]> wrote:

> @Giacomo: DataContext has not to be thread-safe. See
> http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.aspx<http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.aspx>If
> an application wants thread safety around it, it is its own responsibility.
>
> Now in details:
> - thread safety has a cost over performance
> - most of applications use DataContext in a service call, where the service
> method is single-threaded.
> - so most of applications just don't need thread-safety.
> - .NET philosophy about thread safety is currently "do it if you want it",
> probably for the reasons I gave above.
>
> Not that thread safety isn't important, I just mean that thread-safety is
> out of DbLinq scope.
>
>
> On Thu, Apr 23, 2009 at 10:25, Giacomo Tesio <[email protected]> wrote:
>
>> @Jon: does Mono support ReaderWriterLockSlim? have you got some objection
>> about creating a set of static thread safe dictionaries for mappings?
>>
>> @Pascal: is QueryCache thread safe? could it be improved by using the
>> Brian Rudolph code?
>>
>>
>>
>> Giacomo
>>
>>
>> On Wed, Apr 22, 2009 at 4:31 PM, Giacomo Tesio <[email protected]> wrote:
>>
>>> ehm... I'm blind :-D
>>>
>>> Thanks a lot!
>>>
>>>
>>> Giacomo
>>>
>>>
>>> On Wed, Apr 22, 2009 at 4:04 PM, Andrus <[email protected]> wrote:
>>>
>>>>
>>>> http://devplanet.com/blogs/brianr/archive/2008/09/29/thread-safe-dictionary-update.aspx
>>>>
>>>>
>>>> ----- Original Message -----
>>>>  *From:* Giacomo Tesio <[email protected]>
>>>> *To:* [email protected]
>>>> *Sent:* Wednesday, April 22, 2009 4:55 PM
>>>> *Subject:* Re: DataMapper BUG
>>>>
>>>> ???
>>>> where?
>>>>
>>>> On Wed, Apr 22, 2009 at 3:45 PM, Andrus <[email protected]> wrote:
>>>>
>>>>>  There is also 3 days newer blog entry about this:
>>>>>
>>>>> //
>>>>> http://devplanet.com/blogs/brianr/archive/2008/09/29/thread-safe-dictionary-update.aspx
>>>>>
>>>>> Andrus.
>>>>>
>>>>>   ----- Original Message -----
>>>>>  *From:* Giacomo Tesio <[email protected]>
>>>>> *To:* dblinq <[email protected]>
>>>>> *Sent:* Wednesday, April 22, 2009 4:00 PM
>>>>> *Subject:* Re: DataMapper BUG
>>>>>
>>>>> Hello world :-D
>>>>>
>>>>> Working on the lazy loading I've noticed some bugs in the DataMapper.
>>>>>
>>>>> The worse is that it re-evaluate the mapping each time, even if
>>>>> mappings don't change.
>>>>>
>>>>> Fix this bug mean changing the IDataMapper interface too (which is used
>>>>> only in the DataContext and ExpressionDispatcher ).
>>>>>
>>>>> There are two ways:
>>>>> - Create a set of static thread safe dictionaries for mappings [1]
>>>>> - Create a set of static dictionaries filled with all possible results
>>>>> at application startup (toward an init metod? using a static constructor?
>>>>> any idea?)
>>>>>
>>>>> To choose we need to evaluate Mono support, thread safety and
>>>>> performance.
>>>>>
>>>>>
>>>>> I know this is a maior refactoring but I think it could dramatically
>>>>> improve performances.
>>>>>
>>>>>
>>>>>
>>>>> Giacomo
>>>>>
>>>>>
>>>>> [1]
>>>>> For a thread safe dictionary look at
>>>>> http://devplanet.com/blogs/brianr/archive/2008/09/26/thread-safe-dictionary-in-net.aspxbut
>>>>>  note that I've not yet any experience
>>>>> about multi threads on .NET so it should be evaluated)
>>>>>
>>>>>
>>>>>
>>>>> On Tue, Apr 21, 2009 at 2:13 PM, Giacomo Tesio <[email protected]>wrote:
>>>>>
>>>>>> DataMapper.GetEntityRefAssociations() and
>>>>>> DataMapper.GetEntityRefAssociations() depend on Attribute based mapping.
>>>>>>
>>>>>> So XmlMappingSource could not work correctly on EntityRef and
>>>>>> EntitySet (neither on Mono nor on Microsoft.NET).
>>>>>>
>>>>>>
>>>>>>
>>>>>> Giacomo
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DbLinq" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/dblinq?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to