public void GetData(TripsByDistDurCatRow distdurparm) { DataSet ds = new DataSet(); using (AdomdConnection conn = new AdomdConnection("Data Source=miranda;Initial Catalog=bikesMD2")) { conn.Open(); using (AdomdCommand cmd = new AdomdCommand(CommandText(), conn)) { cmd.Parameters.Add(new AdomdParameter("StationPairDistanceMileCategories", distdurparm.DistanceCategory.MemberUniqueName)); cmd.Parameters.Add(new AdomdParameter("TripCatTripCategory", distdurparm.DurationCategory.MemberUniqueName)); cmd.Parameters.Add(new AdomdParameter("StationPairDistanceQtrMiles", distdurparm.DistanceQtrMi.MemberUniqueName)); AdomdDataAdapter adapter = new AdomdDataAdapter(cmd); adapter.Fill(ds); } conn.Close(); } // Single query returns one table DataTable dt = ds.Tables[0]; // read column names to use to select correct fields for data // TBD Inspect here to find column names for pivoted Dayname-bikes Dictionary <string, int> colnbr = new Dictionary <string, int>(); foreach (DataColumn dc in dt.Columns) { colnbr.Add(dc.ColumnName, dc.Ordinal); } foreach (DataRow dr in dt.Rows) { TripsByWeekdayRow oneresult = new TripsByWeekdayRow(distdurparm, dr, colnbr); Add(oneresult); } }
public TripsByWeekdayRow(TripsByDistDurCatRow distanceDurationCategory, DataRow dr, Dictionary <string, int> colnbr) { DistanceDurationCategory = distanceDurationCategory; WeekdayName = new WeekdayNameDimension(dr, colnbr); Bikes = new BikesMeasure(dr, colnbr); SubscriberList = new TripsBySubscriberList(); SubscriberList.GetData(this); }