Exemplo n.º 1
0
        public static ColumnSchemaCollection Filter(this ColumnSchemaCollection columns, FilterRuleSet pkRules, FilterRuleSet generalRules, FilterRuleSet auditRules)
        {
            if (pkRules == null) { throw new Exception("Primary key rules not set"); }
            if (generalRules == null) { throw new Exception("General column rules not set"); }
            if (auditRules == null) { throw new Exception("Audit column rules not set"); }

            var list = new List<ColumnSchema>();

            // IsPrimaryKeyMember & IsAuditColumn always checked to decrease the chance of naming conflicts

            foreach (var column in columns.Where(x => x.IsPrimaryKeyMember && !x.IsAuditColumn()).ToList().ToColumnSchemaCollection().Filter(pkRules))
            {
                if (list.Contains(column)) { throw new Exception("Duplicate column detected while adding primary key columns."); }

                list.Add(column);
            }

            foreach (var column in columns.Where(x => !x.IsPrimaryKeyMember && !x.IsAuditColumn()).ToList().ToColumnSchemaCollection().Filter(generalRules))
            {
                if (list.Contains(column)) { throw new Exception("Duplicate column detected while adding general columns."); }

                list.Add(column);
            }

            foreach (var column in columns.Where(x => !x.IsPrimaryKeyMember && x.IsAuditColumn()).ToList().ToColumnSchemaCollection().Filter(generalRules))
            {
                if (list.Contains(column)) { throw new Exception("Duplicate column detected while adding audit columns."); }

                list.Add(column);
            }

            return list.ToColumnSchemaCollection();
        }
Exemplo n.º 2
0
        public static ColumnSchemaCollection Filter(this ColumnSchemaCollection columns, FilterRuleSet pkRules, FilterRuleSet generalRules, FilterRuleSet auditRules)
        {
            if (pkRules == null)
            {
                throw new Exception("Primary key rules not set");
            }
            if (generalRules == null)
            {
                throw new Exception("General column rules not set");
            }
            if (auditRules == null)
            {
                throw new Exception("Audit column rules not set");
            }

            var list = new List <ColumnSchema>();

            // IsPrimaryKeyMember & IsAuditColumn always checked to decrease the chance of naming conflicts

            foreach (var column in columns.Where(x => x.IsPrimaryKeyMember && !x.IsAuditColumn()).ToList().ToColumnSchemaCollection().Filter(pkRules))
            {
                if (list.Contains(column))
                {
                    throw new Exception("Duplicate column detected while adding primary key columns.");
                }

                list.Add(column);
            }

            foreach (var column in columns.Where(x => !x.IsPrimaryKeyMember && !x.IsAuditColumn()).ToList().ToColumnSchemaCollection().Filter(generalRules))
            {
                if (list.Contains(column))
                {
                    throw new Exception("Duplicate column detected while adding general columns.");
                }

                list.Add(column);
            }

            foreach (var column in columns.Where(x => !x.IsPrimaryKeyMember && x.IsAuditColumn()).ToList().ToColumnSchemaCollection().Filter(generalRules))
            {
                if (list.Contains(column))
                {
                    throw new Exception("Duplicate column detected while adding audit columns.");
                }

                list.Add(column);
            }

            return(list.ToColumnSchemaCollection());
        }
Exemplo n.º 3
0
        public static ColumnSchemaCollection Filter(this ColumnSchemaCollection columns, FilterRuleSet ruleSet)
        {
            if (ruleSet == null) { throw new Exception("Rules not set"); }

            return columns.Filter(ruleSet.Rules, ruleSet.Direction);
        }
Exemplo n.º 4
0
        public static ColumnSchemaCollection Filter(this ColumnSchemaCollection columns, FilterRuleSet ruleSet)
        {
            if (ruleSet == null)
            {
                throw new Exception("Rules not set");
            }

            return(columns.Filter(ruleSet.Rules, ruleSet.Direction));
        }