Ejemplo n.º 1
0
        /// <summary>
        /// Analyses a database table. Reports messages when a table, or its related schema have reserved keyword names.
        /// </summary>
        /// <param name="table">A database table.</param>
        /// <returns>A set of linting messages used for reporting. An empty set indicates no issues discovered.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="table"/> is <c>null</c>.</exception>
        protected IEnumerable <IRuleMessage> AnalyseTable(IRelationalDatabaseTable table)
        {
            if (table == null)
            {
                throw new ArgumentNullException(nameof(table));
            }

            var result = new List <IRuleMessage>();

            var tableNameIsKeyword = Dialect.IsReservedKeyword(table.Name.LocalName);

            if (tableNameIsKeyword)
            {
                var message = BuildTableMessage(table.Name);
                result.Add(message);
            }

            var keywordColumnNames = table.Columns
                                     .Select(c => c.Name.LocalName)
                                     .Where(Dialect.IsReservedKeyword);

            foreach (var kwColumnName in keywordColumnNames)
            {
                var message = BuildTableColumnMessage(table.Name, kwColumnName);
                result.Add(message);
            }

            return(result);
        }