Better way to get code set value?

Posts   
 
    
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 11-May-2005 22:26:45   

I subscribe heavily to the code set way of normalization. For instance, the table Student has a field in it BirthState. Naturally, I have a code set call CdUSStates that has the columns code, abbr, and descr. So, for California, I would have {CA,California,California} in a record.

Now, that means there is a foreign key relationship between Student.BirthState and CdUSStates.Code. When I bulid my EntityCollection filled with StudentEntities, I can do a PrefetchPath to CdUSStates to get the abbr column for each student, but how is this then displayed in a DataGrid? Since I REALLY want to display the Abbr column, is building an EntityCollection what I really want to do? Or instead, do I want to hand build a TypedList?

It seems like there should be a better way to do this. What are the rest of you doing?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 12-May-2005 10:59:20   

NickD wrote:

I subscribe heavily to the code set way of normalization. For instance, the table Student has a field in it BirthState. Naturally, I have a code set call CdUSStates that has the columns code, abbr, and descr. So, for California, I would have {CA,California,California} in a record.

Now, that means there is a foreign key relationship between Student.BirthState and CdUSStates.Code. When I bulid my EntityCollection filled with StudentEntities, I can do a PrefetchPath to CdUSStates to get the abbr column for each student, but how is this then displayed in a DataGrid? Since I REALLY want to display the Abbr column, is building an EntityCollection what I really want to do? Or instead, do I want to hand build a TypedList?

As the relation between student and cdussstates is m:1, you can add a field mapped on related field in student to solve this simple_smile

Frans Bouma | Lead developer LLBLGen Pro
NickD
User
Posts: 224
Joined: 31-Jan-2005
# Posted on: 12-May-2005 16:16:30   

Otis wrote:

As the relation between student and cdussstates is m:1, you can add a field mapped on related field in student to solve this simple_smile

You know that sound you made when you first saw how fast a relational DB could be, or that first time you realised WHY girls are pretty, I just made that sound when I realized how this worked. smile

Now, keeping in mind that I have not even begun to look at the template studio, would it be possible for me to write a template that notices that a row in table A is related to a table that starts with CD_ and therefore bring in the Abbr column from that table as a field mapped on a related field? I want to have all my code set abbrs in the entity by default.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 13-May-2005 11:27:20   

NickD wrote:

Otis wrote:

As the relation between student and cdussstates is m:1, you can add a field mapped on related field in student to solve this simple_smile

You know that sound you made when you first saw how fast a relational DB could be, or that first time you realised WHY girls are pretty, I just made that sound when I realized how this worked. smile

smile

Now, keeping in mind that I have not even begun to look at the template studio, would it be possible for me to write a template that notices that a row in table A is related to a table that starts with CD_ and therefore bring in the Abbr column from that table as a field mapped on a related field? I want to have all my code set abbrs in the entity by default.

In .lpt templates you can indeed. (templates written in C# or VB.NET). These templates should be used on top of the generated code, as they're not mixable with the generated code yet.

Frans Bouma | Lead developer LLBLGen Pro