Shared static readonly LinqMetaData

Posts   
 
    
AlexP
User
Posts: 17
Joined: 24-Jan-2020
# Posted on: 04-Dec-2020 10:53:53   

Hi there,

I'm going through some old code and I'm seeing a lot of this:

static readonly LinqMetaData _metaData = new LinqMetaData();

besides the fact that TransactionToUse will never be disposed (if it's set somewhere), are there also any other issues that might arise?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 05-Dec-2020 10:58:55   

If this is selfservicing, then it might be ok. Still not recommended however. These objects take no time to create so caching them is really not needed. For adapter it's not going to work as the assigned adapter is inside the linqmetadata and all queries produced across threads will share that adapter at that point.

So in short: remove this and re-create the meta-data object per query.

Frans Bouma | Lead developer LLBLGen Pro