public static void BuildClientOrderCollection(MySqlDataReader dr, YellowstonePathology.Business.ClientOrder.Model.ClientOrderCollection clientOrderCollection) { int clientOrderIdCount = 0; while (dr.Read()) { if (dr["ClientOrderIdCount"] != DBNull.Value) { clientOrderIdCount = Convert.ToInt32(dr["ClientOrderIdCount"].ToString()); } } for (int i = 0; i < clientOrderIdCount; i++) { dr.NextResult(); YellowstonePathology.Business.ClientOrder.Model.ClientOrder clientOrder = BuildClientOrder(dr); dr.NextResult(); BuildClientOrderDetailCollection(clientOrder.ClientOrderDetailCollection, dr); if (clientOrder.ClientOrderId != null) { clientOrderCollection.Add(clientOrder); } } }