Given the following schema:
Foo
----------
BarId
FooA
FooB
FooTypeId
FooType [LookUp Table]
----------
TypeC
TypeD
Bar
----------
BarZ
BarStatusId
BarStatus [LookUp Table]
----------
TypeE
The type and settings tables are static, they contain static data that could be mapped to enum
s. A.k.a Lookup tables. Foo
and Bar
are normal tables.
My question is; How do I idiomatically map these lookup tables using Fluent NHibernate? What is the best practice?
class FooType
{
TypeC ...
TypeD ...
}
enum TypeC { ... }
enum TypeD { ... }
Does one maintain a single Entity of FooType
in memory/cache for the application's lifetime? Does one read the FooType
entity from the db every time one wants to use it?
Creating a new FooType()
from code would result in a new FooType
inserted into the lookup table, which is not desired (same data, different table id)
What is best practice when dealing with lookup tables?
Could FooType
be created as a Singleton?