Пример #1
0
        public static CollectionBase GenerateBossCollectionFromReader(IDataReader returnData)
        {
            //creating the instance of Employee collection
            CustomCollection <SecondLevelBoss> colBoss = new CustomCollection <SecondLevelBoss>();

            //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())
            {
                SecondLevelBoss newBoss = new SecondLevelBoss
                                          (
                    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["Country"] == System.DBNull.Value ? string.Empty : (string)returnData["Country"]
                                          );

                colBoss.Add(newBoss);
            }

            //returns the collection of Employee objects
            return(colBoss);
        }//GenerateEmployeeCollectionFromReader
Пример #2
0
        public static CollectionBase GenerateBossCollectionFromReader(IDataReader returnData)
        {
            //creating the instance of Employee collection
            CustomCollection<SecondLevelBoss> colBoss = new CustomCollection<SecondLevelBoss>();

            //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())
            {
                SecondLevelBoss newBoss = new SecondLevelBoss
                (
                    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["Country"] == System.DBNull.Value ? string.Empty : (string)returnData["Country"]
                );

                colBoss.Add(newBoss);
            }

            //returns the collection of Employee objects
            return (colBoss);
        }
Пример #3
0
        //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);
        }