示例#1
0
        /// <summary>
        /// This method fetches all 'Method' objects.
        /// </summary>
        /// <param name='List<PolymorphicObject>'>The 'Method' to delete.
        /// <returns>A PolymorphicObject object with all  'Methods' objects.
        internal PolymorphicObject FetchAll(List <PolymorphicObject> parameters, DataConnector dataConnector)
        {
            // Initial Value
            PolymorphicObject returnObject = new PolymorphicObject();

            // locals
            List <Method> methodListCollection = null;

            // Create FetchAll StoredProcedure
            FetchAllMethodsStoredProcedure fetchAllProc = null;

            // If the data connection is connected
            if ((dataConnector != null) && (dataConnector.Connected == true))
            {
                // Get MethodParameter
                // Declare Parameter
                Method paramMethod = null;

                // verify the first parameters is a(n) 'Method'.
                if (parameters[0].ObjectValue as Method != null)
                {
                    // Get MethodParameter
                    paramMethod = (Method)parameters[0].ObjectValue;
                }

                // Now create FetchAllMethodsProc from MethodWriter
                fetchAllProc = MethodWriter.CreateFetchAllMethodsStoredProcedure(paramMethod);
            }

            // Verify fetchAllProc exists
            if (fetchAllProc != null)
            {
                // Execute FetchAll Stored Procedure
                methodListCollection = this.DataManager.MethodManager.FetchAllMethods(fetchAllProc, dataConnector);

                // if dataObjectCollection exists
                if (methodListCollection != null)
                {
                    // set returnObject.ObjectValue
                    returnObject.ObjectValue = methodListCollection;
                }
            }
            else
            {
                // Raise Error Data Connection Not Available
                throw new Exception("The database connection is not available.");
            }

            // return value
            return(returnObject);
        }