Пример #1
0
        private void EnableDisableIndexes(ITableInfo tableInfo, bool enable)
        {
            if (tableInfo == null)
            {
                throw new ArgumentException("The table info parameter can not be null.");
            }
            ;

            var indexOnOffTemplate = new TurnOnOffIndexes(enable);

            string indexOnOffQuery;

            if (enable)
            {
                indexOnOffQuery = indexOnOffTemplate.TransformText();
            }
            else
            {
                indexOnOffQuery = indexOnOffTemplate.TransformText();
            }

            Console.WriteLine(indexOnOffQuery);
            try
            {
                _queryHelper.ExecuteNonQueryWithoutParams(tableInfo.DbConnectionString, indexOnOffQuery);
            }
            catch (Exception ex)
            {
                var enableDisableStr = enable ? "enable" : "disable";
                throw new IndexServiceException($"Error while trying to {enableDisableStr} indexes.", ex);
            }
        }