예제 #1
0
        /// <summary>
        /// Method to convert SelectableViews Enum to the string of the view name
        /// </summary>
        /// <param name="TableToSelectFrom">Enum Value selected</param>
        /// <returns>String name of the view in Database</returns>
        internal static string GetViewName(SelectableViews TableToSelectFrom)
        {
            string temp = "view_";

            switch (TableToSelectFrom)
            {
            case SelectableViews.Product:
                break;

            case SelectableViews.Country:
                return(temp + "Country");

            case SelectableViews.Role:
                return(temp + "Role");

            case SelectableViews.Profile:
                return(temp + "Profile");

            case SelectableViews.User:
                return(temp + "User");

            case SelectableViews.Session:
                return(temp + "Session");

            default:
                break;
            }

            return(temp);
        }
        /// <summary>
        /// Performs a select statement on the view supplied
        /// </summary>
        /// <param name="ViewToSelect">View to select from</param>
        /// <returns>Result set returned from the database</returns>
        public DataTable Select(SelectableViews ViewToSelect)
        {
            // Set the command text to be executed on the database
            string cmdText = "Select * from " + EnumHelper.GetViewName(ViewToSelect);

            // Initialize the command
            command = InitializeCommand(cmdText, false);
            // Execute the command
            return(PerformSelect(command));
        }