/// <summary> /// This method fetches a 'List<State>' object. /// This method uses the 'States_FetchAll' procedure. /// </summary> /// <returns>A 'List<State>'</returns> /// </summary> public List <State> FetchAllStates(FetchAllStatesStoredProcedure fetchAllStatesProc, DataConnector databaseConnector) { // Initial Value List <State> stateCollection = null; // Verify database connection is connected if ((databaseConnector != null) && (databaseConnector.Connected)) { // First Get Dataset DataSet allStatesDataSet = this.DataHelper.LoadDataSet(fetchAllStatesProc, databaseConnector); // Verify DataSet Exists if (allStatesDataSet != null) { // Get DataTable From DataSet DataTable table = this.DataHelper.ReturnFirstTable(allStatesDataSet); // if table exists if (table != null) { // Load Collection stateCollection = StateReader.LoadCollection(table); } } } // return value return(stateCollection); }
/// <summary> /// This method creates an instance of a /// 'FetchAllStatesStoredProcedure' object and /// creates the sql parameter[] array needed /// to execute the procedure 'State_FetchAll'. /// </summary> /// <returns>An instance of a(n) 'FetchAllStatesStoredProcedure' object.</returns> public static FetchAllStatesStoredProcedure CreateFetchAllStatesStoredProcedure(State state) { // Initial value FetchAllStatesStoredProcedure fetchAllStatesStoredProcedure = new FetchAllStatesStoredProcedure(); // return value return(fetchAllStatesStoredProcedure); }
/// <summary> /// This method fetches all 'State' objects. /// </summary> /// <param name='List<PolymorphicObject>'>The 'State' to delete. /// <returns>A PolymorphicObject object with all 'States' objects. internal PolymorphicObject FetchAll(List <PolymorphicObject> parameters, DataConnector dataConnector) { // Initial Value PolymorphicObject returnObject = new PolymorphicObject(); // locals List <State> stateListCollection = null; // Create FetchAll StoredProcedure FetchAllStatesStoredProcedure fetchAllProc = null; // If the data connection is connected if ((dataConnector != null) && (dataConnector.Connected == true)) { // Get StateParameter // Declare Parameter State paramState = null; // verify the first parameters is a(n) 'State'. if (parameters[0].ObjectValue as State != null) { // Get StateParameter paramState = (State)parameters[0].ObjectValue; } // Now create FetchAllStatesProc from StateWriter fetchAllProc = StateWriter.CreateFetchAllStatesStoredProcedure(paramState); } // Verify fetchAllProc exists if (fetchAllProc != null) { // Execute FetchAll Stored Procedure stateListCollection = this.DataManager.StateManager.FetchAllStates(fetchAllProc, dataConnector); // if dataObjectCollection exists if (stateListCollection != null) { // set returnObject.ObjectValue returnObject.ObjectValue = stateListCollection; } } else { // Raise Error Data Connection Not Available throw new Exception("The database connection is not available."); } // return value return(returnObject); }