I have two classes Car and Drivers:
public class Car
{
public string Status { get; set; }
public IList<Driver> Event { get; set; }
}
public class Driver
{
public string Name { get; set; }
....
}
I get the values from TWO SQL-Statemens (e.g. Select * from car; select * from driver). I can fill the first one with:
while (rdr.Read())
{
_results.Add(new TaskModel(rdr));
//new TaskModel(rdr);
}
where _results is:
private ObservableCollection<Car> _results = new ObservableCollection<Car>();
Constructor for Car looks like:
public Car(IDataRecord record)
{
this.CarId = Convert.ToInt32(record["CARID"]);
this.Color = (string)record["COLOR"];
}
I'm asking myself how to fill the datareader with two statemens and refer in the constructor to get the whole object (Car with Driver)