Hello jaklithn,
[quoted text, click to view] >1) Is it possible to reuse the outer datacontext call for the inner
calculation?
You can expose a method in partial text class, then pass datacontext object
into the method.
But this isn't a good idea, because we have to call that method by ourself.
[quoted text, click to view] >2) Can I tell the inner datacontext not to take part in the outer
transaction?
When you instantiate TransactionScope, the transaction manager determines
which transaction to participate in. The decision is based on whether an
ambient transaction is present and the value of the TransactionScopeOption
parameter in the constructor. If the scope is instantiated with Suppress,
it never takes part in a transaction, regardless of whether an ambient
transaction is present. You can wrap your onload method into an suppress
transaction scope.
More detailed information:
http://msdn2.microsoft.com/en-us/library/ms172152.aspx [Implementing an Implicit Transaction using Transaction Scope]
[quoted text, click to view] >3) Is there a better way to set the value of the inner private variable
_childrenCount?
In my opinion, I would like to create a Utility Class which exposes a count
method. In that method, it will return the clidrencount if we pass parent
id into it. We can define a datacontext instance in that class, and ensure
it could only be created once (such as singleton). If the count number of
children rows doesn't change often, we can also insert the number into
hashtable after query. Thereby, in the next time, we just need to get
number from hashtable instead of querying database again.
[quoted text, click to view] >4) Should I configure DTC and/or exchange TransationScope with Transaction?
I think you needn't. You can specify TransactionScopeOption to suppress if
you needn't inner datacontext to be involved into outer transaction.
Moreover, Transaction could also be a good solution. But I don't think it's
necessary for you to configure DTC.
Hope this helps, please feel free to let us know if you have any more
concern. We are glad to assist you.
Have a great day,
Best regards,
Wen Yuan
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx. ==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.