예제 #1
0
        private AggregateRoot DefineField(SchemaSpecification schema)
        {
            var table = schema.CreateTable("Field");

            var id   = table.CreateIdentityColumn("FieldId");
            var pk   = table.CreatePrimaryKey(id);
            var name = table.CreateStringColumn("Name", 20);

            return(new AggregateRoot(pk));
        }
예제 #2
0
        private static void DefineContribution(SchemaSpecification schema, AggregateRoot mathematician)
        {
            var table = schema.CreateTable("Contribution");

            var contributionId  = table.CreateIdentityColumn("ContributionId");
            var pk              = table.CreatePrimaryKey(contributionId);
            var mathematicianId = table.CreateIntColumn("MathematicianId");
            var description     = table.CreateStringColumn("Description", 500);

            var indexMathematicianId = table.CreateIndex(mathematicianId);
            var fkMathematician      = indexMathematicianId.CreateForeignKey(mathematician.PrimaryKey);
        }
예제 #3
0
        private static AggregateRoot DefineMathematician(SchemaSpecification schema)
        {
            var table = schema.CreateTable("Mathematician");

            var mathematicianId = table.CreateIdentityColumn("MathematicianId");
            var pk        = table.CreatePrimaryKey(mathematicianId);
            var name      = table.CreateStringColumn("Name", 100);
            var birthYear = table.CreateIntColumn("BirthYear");
            var deathYear = table.CreateIntColumn("DeathYear", nullable: true);

            return(new AggregateRoot(pk));
        }
예제 #4
0
        private void CreateMathematician(DatabaseSpecification db, SchemaSpecification dbo)
        {
            var table = dbo.CreateTable("Mathematician");

            var id     = table.CreateIdentityColumn("MathematicianId");
            var unique = table.CreateGuidColumn("Unique");

            var pk = table.CreatePrimaryKey(id);

            table.CreateUniqueIndex(unique);

            CreateMathematicianName(dbo, pk);
        }
예제 #5
0
        public static void CreateMutableProperty(this SchemaSpecification schema, Entity entity, string propertyName, Action <TableSpecification> definitions)
        {
            var table = schema.CreateTable($"{entity.Name}{propertyName}");
            var id    = table.CreateIdentityColumn($"{entity.Name}{propertyName}Id");
            var fkid  = table.CreateIntColumn($"{entity.Name}Id");
            var index = table.CreateIndex(fkid);

            index.CreateForeignKey(entity.PrimaryKey);
            definitions(table);
            var propertyPk = table.CreatePrimaryKey(id);

            var predecessor   = schema.CreateTable($"{entity.Name}{propertyName}Predecessor");
            var predecessorId = predecessor.CreateIntColumn("Predecessor");
            var successorId   = predecessor.CreateIntColumn("Successor");

            predecessor.CreatePrimaryKey(predecessorId, successorId);
            var predecessorIndex = predecessor.CreateIndex(predecessorId);
            var successorIndex   = predecessor.CreateIndex(successorId);

            predecessorIndex.CreateForeignKey(propertyPk);
            successorIndex.CreateForeignKey(propertyPk);
        }
예제 #6
0
        private static void CreateMathematicianNamePrior(SchemaSpecification dbo, PrimaryKeySpecification mathematicianPk)
        {
            var table = dbo.CreateTable("MathematicianNamePrior");

            var currentId = table.CreateIntColumn("MathematicianNameId");
            var priorId   = table.CreateIntColumn("PriorMathematicianNameId");

            var currentIndex = table.CreateIndex(currentId);
            var currentFk    = currentIndex.CreateForeignKey(mathematicianPk);

            var priorIndex = table.CreateIndex(priorId);
            var priorFk    = priorIndex.CreateForeignKey(mathematicianPk);

            var pk = table.CreatePrimaryKey(currentId, priorId);
        }
        public static Entity CreateEntity(this SchemaSpecification schema, string tableName,
                                          Action <TableSpecification> definitions)
        {
            var table = schema.CreateTable(tableName);
            var id    = table.CreateIdentityColumn($"{tableName}Id");

            definitions(table);
            var pk = table.CreatePrimaryKey(id);

            return(new Entity
            {
                Name = tableName,
                Table = table,
                IdColumn = id,
                PrimaryKey = pk
            });
        }
예제 #8
0
        private void CreateMathematicianName(SchemaSpecification dbo, PrimaryKeySpecification mathematicianPk)
        {
            var table = dbo.CreateTable("MathematicianName");

            var id = table.CreateIdentityColumn("MathematicianNameId");
            var mathematicianId = table.CreateIntColumn("MathematicianId");
            var firstName       = table.CreateStringColumn("FirstName", 50);
            var lastName        = table.CreateStringColumn("LastName", 50);
            var hashCode        = table.CreateFixedBinaryColumn("HashCode", 32);

            var index = table.CreateIndex(mathematicianId);
            var fk    = index.CreateForeignKey(mathematicianPk);

            var pk = table.CreatePrimaryKey(id);

            CreateMathematicianNamePrior(dbo, pk);
        }