Can RefCount on ContextManager be public?

Can RefCount on ContextManager be public?

Old forum URL: forums.lhotka.net/forums/t/6476.aspx


detritus posted on Saturday, February 21, 2009

Hi Rocky,

I want to set ObjectTrackingEnabled property of DataContext to false for read-only operations (Fetch) to increase performance. Since this property cannot be changed if any sql statement executed previously, I need to know if the DataContext returned from GetManager method is a brand new one or reusing an old one. I think the easiest way I can do that is to check the value of RefCount on ContextManager but that variable is not accessable. Is it possible for this property to be public?

Thanks in advance,
Sinan.

RockfordLhotka replied on Sunday, February 22, 2009

public read-only? Seems harmless enough. I'll add this to the wish list.

xal replied on Thursday, April 02, 2009

I'd like to cast my vote on this one as well, since it's simple enough and I find it really important for certain scenarios.

A great example of this is when for some reason need to create and save a root object while saving another root object. I realise this is an edge case and that you can create and internal insert method that doesn't attempt to commit a transaction, but when you're relying heavily on code generation this starts to get messy.

Anyway, if we had this instead of always calling ctx.Transaction.Commit() you could do:
If ctx.RefCount = 1 Then ctx.Transaction.Commit()

It also has the added bonus of letting it all be done within the same transaction, which brings the TransactionScope feel to it, since it's all done without effort and without having the need to pass parameters around.

Andrés

RockfordLhotka replied on Thursday, April 02, 2009

It is on the wish list

http://www.lhotka.net/cslabugs/edit_bug.aspx?id=355

 

Rocky

Copyright (c) Marimer LLC