ApplicationContext.LocalContext["cn"] = cn;

ApplicationContext.LocalContext["cn"] = cn;

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


FreeAsInBeer posted on Wednesday, December 27, 2006

I've been looking at the ProjectTracker demo to try and understand the models Rocky uses, and I've come across this interesting thing.

The DataPortal_Update() method in Resource.cs has this bit of code;

ApplicationContext.LocalContext["cn"] = cn;

But Project.cs's DataPortal_Update() method does not.

Why the difference? I thought perhaps one was RunLocal (is that the CSLA term?), but it doesnt seem that way.

Maybe it's just a case of Project.cs not getting updated with that bit of code when the v2.1 demo was done?

RockfordLhotka replied on Thursday, December 28, 2006

It is intentional. As an author, I am stuck in this situation where I need to show multiple ways to solve the same problem in order to educate and inspire people to use the right solution for their particular scenario.

Project uses one approach when talking to the database, and Resource uses a different approach. Also notice that Project uses a Guid id, while Resource uses an Integer id - again, this is an arbitrary difference so I can illustrate two techniques to accomplish essentially the same goal.

The use of LocalContext in Resource is new for 2.1, but even in 2.0 Project and Resource worked differently.

It is important to note that Project is actually not ideal due to the unfortunate way System.Transactions works. Project and its children open many db connections, while ultimately forces the DTC to be used by System.Transactions (which is a flaw in Microsoft's implementation imo).

Resource is a better implementation in both 2.0 and 2.1, because it uses a single db connection and avoids the use of the DTC.

However, Project is a perfectly good implementation if you use Enterprise Services transactions...

It is all a series of tradeoffs...

FreeAsInBeer replied on Thursday, December 28, 2006

RockfordLhotka:
It is all a series of tradeoffs...


hey, what isnt? Every silly thing I do seems to have a thousand pros and a thousand cons! :)

Thanks for the reply. I'll have a closer look at things now, and keep in mind what you've said.

FaiB

Copyright (c) Marimer LLC