Ejemplo n.º 1
0
        public override void HandleNode()
        {
            ChkColumnRefTables = ASTHelperMethod.GetTableRefsInCurSelect(Node).Where(d =>
            {
                if (d.Type != 1)
                {
                    return(false);
                }
                return(DatabaseManager.GetTableColumns(d.TableName).Contains(ColumnName));
            }).ToList();

            if (!string.IsNullOrEmpty(TableName))
            {
                ChkColumnRefTables.RemoveAll(t => !t.TableName.Equals(TableName, StringComparison.InvariantCultureIgnoreCase));
            }

            var boolComparsions = Node.SelectNodes(".//SqlComparisonBooleanExpression");

            foreach (XmlNode boolComparsion in boolComparsions)
            {
                DoValidStatus(boolComparsion);
            }

            if (ChkColumnRefTables.Count > 0)
            {
                ChkColumnRefTables.ForEach(t =>
                {
                    WriteLog(string.Format("Table [{0}] does not contain the filter {1}", t.TableName, Filter), 2, t.LocationStr);
                });
            }
        }
Ejemplo n.º 2
0
        private void DoValidStatus(XmlNode n)
        {
            var schemaName = DoValidInternal(n);

            if (!string.IsNullOrEmpty(schemaName))
            {
                var tableName  = ASTHelperMethod.GetTableNameIfHasAlias(StyleCopContext.Doc, schemaName);
                var firstMatch = ChkColumnRefTables.FirstOrDefault(t => schemaName.Equals(t.Alias, StringComparison.InvariantCultureIgnoreCase));
                if (firstMatch == null)
                {
                    firstMatch = ChkColumnRefTables.FirstOrDefault(t => t.TableName.Equals(tableName, StringComparison.InvariantCultureIgnoreCase));
                }
                if (firstMatch != null)
                {
                    ChkColumnRefTables.Remove(firstMatch);
                }
            }
        }