When I need to grab more than one record from table(database), my method populates List of particular class (all of my data access layer methods use List for set based select statements. I Don't use datatable/dataset or xmlDocument approach). So lets suppose next simplified scenario; I have two classes – customer and order with these fields/properties:
Class Customer{
int IDCustomer
string CustomerName
string CustomerAddress
string CustomerCity
}
Class Order{
int IDOrder
int IDCustomer
string SalePersonName
decimal OrderSubTotal
datetime OrderDateCreated
}
So, lets say that we need a method which deliver to the UI (ObjectDataSource) all data from Order Class properties + CustomerName and CustomerCity from Customer class. I want my method from Order class looks like:
public List<Order> SelectAll(){
}
so which approach should I use to accomplish this? How to setup Order Class so it contain that two extra properties (CustomerName and CustomerCity) concerning best practices, object oriented paradigm, performance etc. :
APROACH A:
Class Order{
int IDOrder
int IDCustomer
string SalePersonName
decimal OrderSubTotal
datetime OrderDateCreated
//--- plus two extra properties of type string
string CustomerName
string CustomerCity
}
APROACH B:
Class Order{
int IDOrder
int IDCustomer
string SalePersonName
decimal OrderSubTotal
datetime OrderDateCreated
//--- plus extra property of type Customer
Customer _Customer
}
APROACH C:
???
I am on .NET 2.0.
Thank you people for your time.