That's the only true way to achieve a lazy-loaded singleton in .NET. All
other methods will generally result in a [very very] slim possibility for
threading issues (As a matter of fact, the most used approach, double-locks
doesn't even work in Java, even though it's very widely used).
Given that it IS the correct implementation of a common design pattern, the
best we can do given the information provided is tell you that everything
looks ok. The question is whether you want LaborRateDataMa pper instance
within your ApplicationMana ger to be a singleton -which is something no one
will be able to answer.
A couple notes though, there's a growing movement which feels that the
singleton is actually an anti-pattern. Also, static constructors introduce
a performance [very slight] performance penalty since any access to _any_
class members requires the CLR to check if the static constructor has
already been executed. FxCop will report this issue.
As for your problem, I can only guess that you have another instance of
LaborRateDataMa pper somewhere. It would seem (although it's very hard to
tell), that the LaborRateDataMa pper singleton should be implemented inside
the LaborRateDataMa pper class, and not the ApplicationMana ger class -
although that's just a guess.
Karl
--
http://www.openmymind.net/ http://www.fuelindustries.com/
"Randy Smith" <rs****@cta.org wrote in message
news:OB******** ******@TK2MSFTN GP04.phx.gbl...
Hi ALL,
Our consultant added the datamapper definitions to our
ApplicationMana ger.cs file. Has anyone else used this technique, and how
has it benefited you? Here is what a sample of it looks like:
public static LaborRateDataMa pper LaborRateDM;
static ApplicationMana ger()
{
LaborRateDM = new LaborRateDataMa pper();
}
I've added 3 rows to my LaborRateTable, which appears via the
ApplicationMana ger datamapper. BUT, if I try to access these same rows
directly via LaborRateTable, the system is telling me that there are no
records.
Any ideas?
TIA, Randy Smith