Example #1
0
        protected MethodUniqueValidator CreateMethodUniqueValidator(UniqueConstraint unique)
        {
            StringBuilder methodName = new StringBuilder("FindBy");

            foreach (DataColumn col in unique.Columns)
            {
                methodName.Append(col.ColumnName);
            }

            MethodInfo method = this.Table.GetType().GetMethod(methodName.ToString());

            if (method == null)
            {
                return(null);
            }

            MethodUniqueValidator validator = new MethodUniqueValidator(this, unique, method);

            return(validator);
        }
Example #2
0
        protected virtual void PopulateUniques()
        {
            foreach (Constraint constraint in this.Table.Constraints)
            {
                UniqueConstraint unique = constraint as UniqueConstraint;
                if (unique == null)
                {
                    continue;
                }

                MethodUniqueValidator muv = this.CreateMethodUniqueValidator(unique);
                if (muv != null)
                {
                    this.uniques.Add(muv);
                    continue;
                }

                IUniqueValidator uv = new DictionaryUniqueValidator(this, unique);
                this.uniques.Add(uv);
            }
        }