Home All Groups Group Topic Archive Search About

How to reinforce types without composition/inheritance

Author
7 Mar 2007 7:56 PM
Barry Gilbert
The answer might be obvious, but I'm looking for inout on the following
scenario.

I have a class called Employee that looks like this:

Public Class Employee
   Private _employeeId As Int16
   Public Property Id As Int16
        Get
         blah, blah......

This class is mapped to an Employees table and empId maps to the table's
primary key.

I have another class called Attendance. It maps to a table called
Attendence, which has a foreign key (employeeId) to the Employees table.

In the Attendance class, I want to store the employeeId value I retrieved
from the Attendance table. Because the value is a simple one, I don't want to
instantiate a new Employee object for each Attendance object. However, I do
want to reinforce the same type in both classes.

The idea is to prevent coding incorrect types. If I were doing something
like this in SQL Server, I would consider a UDT. I'm looking for a similar
technique in .Net.

Would a Structure somehow fill this requirement? Is there some better
practice? Should I simply maintain a data dictionary somewhere and tape it to
the wall? I welcome your thoughts.

Barry

AddThis Social Bookmark Button