Exemple #1
0
        public Table Inherits(List <Table> otherTables)
        {
            var inheritedDependency =
                ForeignKeys.FirstOrDefault(x => PrimaryKeys.Any(y => y.DbColumnName == x.DbColumnName));

            if (inheritedDependency != null)
            {
                return(otherTables.FirstOrDefault(x => x.DbTableName == inheritedDependency.ForeignKeyTargetTable));
            }
            return(null);
        }
Exemple #2
0
        public virtual ForeignKey FindForeignKey(
            [NotNull] EntityType principalType,
            [CanBeNull] string navigationToPrincipal,
            [CanBeNull] string navigationToDependent,
            [CanBeNull] IReadOnlyList <Property> foreignKeyProperties,
            [CanBeNull] IReadOnlyList <Property> principalProperties,
            bool?isUnique)
        {
            Check.NotNull(principalType, nameof(principalType));

            return(ForeignKeys.FirstOrDefault(fk =>
                                              fk.IsCompatible(
                                                  principalType,
                                                  this,
                                                  navigationToPrincipal,
                                                  navigationToDependent,
                                                  foreignKeyProperties,
                                                  principalProperties,
                                                  isUnique)));
        }
Exemple #3
0
 public ConstraintInfo FindConstraint(ConstraintInfo cnt)
 {
     if (cnt is PrimaryKeyInfo)
     {
         return(PrimaryKey);
     }
     if (cnt is ForeignKeyInfo)
     {
         return(ForeignKeys.FirstOrDefault(x => x.ConstraintName == cnt.ConstraintName));
     }
     if (cnt is IndexInfo)
     {
         return(Indexes.FirstOrDefault(x => x.ConstraintName == cnt.ConstraintName));
     }
     if (cnt is UniqueInfo)
     {
         return(Uniques.FirstOrDefault(x => x.ConstraintName == cnt.ConstraintName));
     }
     if (cnt is CheckInfo)
     {
         return(Checks.FirstOrDefault(x => x.ConstraintName == cnt.ConstraintName));
     }
     return(null);
 }