Reputation: 17
First i want to tell you that i am new to OOP concept, but i like to learn this in order to survive to this OOP world :). So, i just have a project, data entry asp.net web form application. I want to separate this app in 3 layers (is first time). I have my database in place, now i make my dto's in order to exchange objects state between layers. I don'T know how to repreaent the lookup tables values in my classes?! Let's say I have the following tables:
Patient table
PatientID int
PatientName varchar
PatientStateID int (fk States table)
State table
StateID int (pk)
StateName varchar
Now i have the Patients class DTO
public class Patient
{
public int PatientID {get; set;}
public string PatientName{get;set}
// and now the problem
How to represent State property?
public int PatientStateID {get; set;}
public string StateName {get; set}
}
For this i know, i have i stored proc in sql that make the join and return all the needed data. But is ok? Or i need to make classes for that lookup tables too?
Thank you very much for your help!
Upvotes: 1
Views: 190
Reputation: 1010
You can refer to the State like so:
public class Patient
{
public string Name {get; set;}
public State MyState {get; set;}
}
EDIT: changed the Setter clause to give correct syntax
And you can refer to Patient.MyState.Statename
for example to get the desired info.
Good luck!
Upvotes: 2