public static CollectionBase GenerateBossCollectionFromReader(IDataReader returnData) { //creating the instance of Employee collection CustomCollection <FirstLevelBoss> colBoss = new CustomCollection <FirstLevelBoss>(); //Iterating through the data reader, to generate Employee collection. //each iteration cause to create a separate instance of Employee and be added to the Employee collection. while (returnData.Read()) { FirstLevelBoss newBoss = new FirstLevelBoss ( returnData["EmployeeId"] == System.DBNull.Value ? GetIdMinValue : (int)returnData["EmployeeId"], returnData["LastName"] == System.DBNull.Value ? string.Empty : (string)returnData["LastName"], returnData["FirstName"] == System.DBNull.Value ? string.Empty : (string)returnData["FirstName"], returnData["Title"] == System.DBNull.Value ? string.Empty : (string)returnData["Title"] ); colBoss.Add(newBoss); } //returns the collection of Employee objects return(colBoss); }//GenerateEmployeeCollectionFromReader
public static CollectionBase GenerateBossCollectionFromReader(IDataReader returnData) { //creating the instance of Employee collection CustomCollection<FirstLevelBoss> colBoss = new CustomCollection<FirstLevelBoss>(); //Iterating through the data reader, to generate Employee collection. //each iteration cause to create a separate instance of Employee and be added to the Employee collection. while (returnData.Read()) { FirstLevelBoss newBoss = new FirstLevelBoss ( returnData["EmployeeId"] == System.DBNull.Value ? GetIdMinValue : (int)returnData["EmployeeId"], returnData["LastName"] == System.DBNull.Value ? string.Empty : (string)returnData["LastName"], returnData["FirstName"] == System.DBNull.Value ? string.Empty : (string)returnData["FirstName"], returnData["Title"] == System.DBNull.Value ? string.Empty : (string)returnData["Title"] ); colBoss.Add(newBoss); } //returns the collection of Employee objects return (colBoss); }
//Utils.GenerationCommandType.CustomEntityTabularCollection public static ArrayList SelectTwoLevelBossesCustomEntity() { IDataReader myDataReader; // Execute SQL Command SqlConnection cn = new SqlConnection(ConnectionStringManager.DefaultDBConnectionString); SqlCommand sqlCmd = new SqlCommand(); sqlCmd.Connection = cn; DatabaseUtility.SetCommandType(sqlCmd, CommandType.StoredProcedure, SP_CUSTOM_EMPLOYEES_GETTWOLEVELBOSSES); cn.Open(); myDataReader = sqlCmd.ExecuteReader(); CustomCollection <FirstLevelBoss> objFirstLevelBossCollection = (CustomCollection <FirstLevelBoss>)FirstLevelBoss.GenerateBossCollectionFromReader(myDataReader); //moving the data reader for next result set myDataReader.NextResult(); CustomCollection <SecondLevelBoss> objSecondLevelBossCollection = (CustomCollection <SecondLevelBoss>)SecondLevelBoss.GenerateBossCollectionFromReader(myDataReader); ArrayList customEntitySet = new ArrayList(); customEntitySet.Add(objFirstLevelBossCollection); customEntitySet.Add(objSecondLevelBossCollection); cn.Close(); return(customEntitySet); }