Right now I have a table called CodeSet and one called CodeValue. Many CodeValues to a CodeSet. Based on the data entered in the the two tables I want to generate CodeSet classes for each row of data in in the CodeSet table and a class for each row of data in the CodeValue table. I currently have a custom built Code Generation console app for doing this. It's a home brew solution with my own templates. I actually use LLBLGen's entities for loading the data and doing this in my custom solution but as I learn more about creating LLBLGen templates I thought it would be nice to include it as a task in my LLBLGen project so all my code generation was self contained in one area (a LLBLGen project).
There are currently a number of classes involved in this solution so I can't include everything here but I pasted a simple example of what gets generated based on values in the two tables. This example is a CodeSet (Status) and two CodeValue's (Active & InActive) that have FK relations back to the Status CodeSet. My app generates the class Status with properties for each CodeValue that are of type StatusCodeValue, also generate by the tool.
public class StatusCodeValue : CodeValue
{
public StatusCodeValue(CodeValueEntity codeValueEntity) : base(codeValueEntity){}
}
public class Status : CodeSetUIBase //CodeSet entry
{
public Status() : base("Status") { }
public StatusCodeValue Active
{
get { return (StatusCodeValue) CodeSetManager.GetCodeValue(this.CodeSetName, "ACTIVE"); }
}
public StatusCodeValue InActive
{
get { return (StatusCodeValue) CodeSetManager.GetCodeValue(this.CodeSetName, "INACTIVE"); }
}
}
It's my way of creating a list of Enum in a table but being able to code using the values using strongly type objects. Of course, there are a few other fields in the table that allow for more flexibility than a enum. Many of my tables in the schema have FK's to CodeValues.