Guys I have another "best practice question"
For example I have this tables on my Sql Server:
--------------
Table: Client
--------------
(PK) clientID long,
clientName varchar(50)
---------------
Table: Training
---------------
(PK) trainingID long,
(FK) clientID long,
trainingName varchar(50)
Now Im using LINQ2SQL to map those tables.- But if now I want to create a business layer what Im doing is creating plain objects modelling those tables.- For example:
public class Client
{
public long clientID {get; set;
public string clientName {get; set;}
}
public class Training
{
public long trainingID {get; set;}
// And here goes my question!!
public long clientID {get; set;} // <--- Should this be here
public string trainingNane {get; set;}
}
or should I remove it from there and modify my Client class to this:
public class Client
{
public long clientID {get; set;
public string clientName {get; set;}
public List<Training> myTrainings {get; set;} //Clients have Trainings!
}
I mean should I create the classes as the DB is or should I use the common sense and figure that a client has many trainings (I will then create a method to find his courses) a method like this (could be on a ClientHelper class):
public List<Training> findMyTranings(long clientID)
{
// Find the Trainings for that particular client
}
I hope you understand this stupid question, is about how to model the classes.-
Thanks in advanced!!