コード例 #1
0
ファイル: ModelConstructor.cs プロジェクト: jasmina94/LMS
 public void ConstructDomainModelData <T1, T2>(DomainModelBuilder <T1, T2> domainModelBuilder)
     where T1 : BaseData
     where T2 : ViewModel
 {
     domainModelBuilder.BuildBaseData();
     domainModelBuilder.BuildConcreteData();
 }
コード例 #2
0
            protected override void Act()
            {
                var builder = new DomainModelBuilder();

                builder.AddAggregate(
                    new AggregateDefinition(
                        new FullName("schema", "Aggregate1"),
                        new[]
                {
                    new FullName("schema", "Entity1")
                }));

                builder.AddEntity(
                    new EntityDefinition(
                        "schema",
                        "Aggregate1",
                        new EntityPropertyDefinition[0],
                        new EntityIdentifierDefinition[0]));

                builder.AddEntity(
                    new EntityDefinition(
                        "schema",
                        "Entity1",
                        new EntityPropertyDefinition[0],
                        new EntityIdentifierDefinition[0]));

                builder.AddEntity(
                    new EntityDefinition(
                        "schema",
                        "Entity2",
                        new EntityPropertyDefinition[0],
                        new EntityIdentifierDefinition[0]));

                var model = builder.Build();
            }
コード例 #3
0
            protected override void Arrange()
            {
                DomainModelBuilder builder = new DomainModelBuilder();

                builder.AddSchema(new SchemaDefinition("schema", "schema"));

                builder.AddAggregate(
                    new AggregateDefinition(
                        new FullName("schema", "Entity1"),
                        new FullName[]
                        { }));

                builder.AddEntity(
                    new EntityDefinition(
                        "schema",
                        "Entity1",
                        new EntityPropertyDefinition[]
                        { },
                        new EntityIdentifierDefinition[]
                        { }));

                var domainModel = builder.Build();

                _nonAggregateExtensionEntity = domainModel.Entities.First();
            }
コード例 #4
0
        protected override void Act()
        {
            var domainModelDefinitions = new DomainModelDefinitions(
                new SchemaDefinition("schema", "schema"),
                new[]
            {
                new AggregateDefinition(
                    new FullName("schema", "Aggregate"),
                    new[]
                {
                    new FullName("schema", "AChild")
                })
            },
                new[]
            {
                new EntityDefinition("schema", "Aggregate", new EntityPropertyDefinition[0], new EntityIdentifierDefinition[0]),
                new EntityDefinition("schema", "AChild", new EntityPropertyDefinition[0], new EntityIdentifierDefinition[0])
            },
                new AssociationDefinition[0],
                new AggregateExtensionDefinition[0]);

            var builder = new DomainModelBuilder(
                new[]
            {
                domainModelDefinitions
            });

            _domainModel = builder.Build();
        }
コード例 #5
0
        private static DomainModelBuilder CreateValidDomainModel()
        {
            var entityDefinitions = new[]
            {
                new EntityDefinition(
                    "DefinedSchema",
                    "Entity1",
                    new[]
                {
                    new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                },
                    new[]
                {
                    new EntityIdentifierDefinition(
                        "PK",
                        new[]
                    {
                        "KeyProperty1", "KeyProperty2"
                    },
                        isPrimary: true)
                },
                    true)
            };

            var associationDefinitions = new AssociationDefinition[]
            { };

            var aggredateDefinitions = new[]
            {
                new AggregateDefinition(
                    new FullName("DefinedSchema", "Entity1"),
                    new FullName[]
                    { })
            };

            //  schema names do not match the names on the AggregateDefinition
            var schemaDefinition = new SchemaDefinition("logicalName", "DefinedSchema");

            var modelDefinitions = new DomainModelDefinitions(
                schemaDefinition,
                aggredateDefinitions,
                entityDefinitions,
                associationDefinitions);

            var domainModelDefinitionsProvider = MockRepository.GenerateStub <IDomainModelDefinitionsProvider>();

            domainModelDefinitionsProvider.Stub(x => x.GetDomainModelDefinitions())
            .Return(modelDefinitions);

            DomainModelBuilder builder = new DomainModelBuilder();

            builder.AddDomainModelDefinitionsList(
                new List <DomainModelDefinitions>
            {
                domainModelDefinitionsProvider.GetDomainModelDefinitions()
            });

            return(builder);
        }
コード例 #6
0
            protected override void Act()
            {
                var builder = new DomainModelBuilder();

                builder.AddSchema(
                    new SchemaDefinition("TestLogicalName", SystemConventions.AuthSchema));

                builder.Build();
            }
コード例 #7
0
            protected override void Act()
            {
                var builder = new DomainModelBuilder();

                builder.AddSchema(
                    new SchemaDefinition(SystemConventions.AuthSchema, "TestPhysicalName"));

                _model = builder.Build();
            }
コード例 #8
0
        public void CommonModelSetup()
        {
            var modelBuilder = new DomainModelBuilder()
                               .HasModelName("Sales");

            modelBuilder.Entity <Invoice>().HasKey(x => x.Id);
            modelBuilder.Entity <InvoiceLine>().HasKey(x => x.Id);
            modelBuilder.Entity <Product>().HasKey(x => x.Id);

            modelBuilder.Entity <Person>().HasKey(x => x.Id);
            modelBuilder.Entity <Customer>().HasKey(x => x.Id)
            .IgnoreMember(x => x.StringComparer);

            var model = modelBuilder.Build();
        }
コード例 #9
0
            protected override void Act()
            {
                var builder = new DomainModelBuilder();

                builder.AddAggregate(
                    new AggregateDefinition(
                        new FullName("schema", "Aggregate1"),
                        new[]
                {
                    new FullName("schema", "TargetEntity")
                }));

                builder.AddEntity(
                    new EntityDefinition(
                        "schema",
                        "Aggregate1",
                        new EntityPropertyDefinition[0],
                        new EntityIdentifierDefinition[0]));

                builder.AddEntity(
                    new EntityDefinition(
                        "schema",
                        "TargetEntity",
                        new[]
                {
                    CreateInt32Property()
                },
                        new EntityIdentifierDefinition[0]));

                builder.AddAssociation(
                    new AssociationDefinition(
                        new FullName("schema", "association1"),
                        Cardinality.OneToZeroOrMore,
                        new FullName("schema", "SourceEntity"),
                        new[]
                {
                    CreateInt32Property()
                },
                        new FullName("schema", "TargetEntity"),
                        new[]
                {
                    CreateInt32Property()
                },
                        false,
                        false));

                var model = builder.Build();
            }
コード例 #10
0
            protected override void Act()
            {
                var builder = new DomainModelBuilder();

                builder.AddAggregate(
                    new AggregateDefinition(
                        new FullName("schema", "Aggregate1"),
                        new[]
                {
                    new FullName("schema", "Entity1"), new FullName("schema", "Entity2")
                }));

                builder.AddAggregate(
                    new AggregateDefinition(
                        new FullName("schema", "Aggregate2"),
                        new[]
                {
                    new FullName("schema", "Entity2")
                }));
            }
コード例 #11
0
        protected override void Act()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddAggregate(new AggregateDefinition(new FullName("schema", "Student"), new FullName[0]));

            // Execute code under test
            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "Student",
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("FirstName", new PropertyType(DbType.String, 50), string.Empty, false),
                new EntityPropertyDefinition("StudentUniqueId", new PropertyType(DbType.String, 50), string.Empty, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_Student",
                    new[]
                {
                    "StudentUSI"
                },
                    true),
                new EntityIdentifierDefinition(
                    "AK_Student_StudentUniqueId",
                    new[]
                {
                    "StudentUniqueId"
                },
                    false)
            }));

            domainModelBuilder.AddSchema(new SchemaDefinition("schema", "schema"));

            var domainModel = domainModelBuilder.Build();

            _entity = domainModel.EntityByFullName[new FullName("schema", "Student")];
        }
コード例 #12
0
        /// <summary>
        /// Creates a Student resource with the necessary Entity and Aggregate instances to obtain the correct name.
        /// </summary>
        /// <returns></returns>
        private static Resource CreateStudentResource()
        {
            var domainModelBuilder = new DomainModelBuilder();

            var schema = EdFiConventions.PhysicalSchemaName;

            var entityName = new FullName(schema, "Student");

            domainModelBuilder.AddAggregate(new AggregateDefinition(entityName, new FullName[0]));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    schema,
                    "Student",
                    new EntityPropertyDefinition[0],
                    new EntityIdentifierDefinition[0]));

            domainModelBuilder.AddSchema(new SchemaDefinition(EdFiConventions.LogicalName, schema));

            var domainModel = domainModelBuilder.Build();

            var resourceModel = new ResourceModel(domainModel);

            var entity = domainModel.EntityByFullName[entityName];

            // Create the Resource using the Entity
            var resource =
                (Resource)
                Activator.CreateInstance(
                    typeof(Resource),
                    BindingFlags.NonPublic | BindingFlags.Instance,
                    null,
                    new object[]
            {
                resourceModel,
                entity
            },
                    CultureInfo.CurrentCulture);

            return(resource);
        }
コード例 #13
0
        private static Resource_Resource GetTestResource()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "TestEntity1",
                    new[]
            {
                new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("StringProperty1", new PropertyType(DbType.String), null, false),
                new EntityPropertyDefinition("DateProperty1", new PropertyType(DbType.Date), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK",
                    new[]
                {
                    "KeyProperty1"
                },
                    isPrimary: true)
            }));

            domainModelBuilder.AddAggregate(new AggregateDefinition(new FullName("schema1", "TestEntity1"), new FullName[0]));

            domainModelBuilder.AddSchema(new SchemaDefinition("schema1", "schema1"));
            domainModelBuilder.AddSchema(new SchemaDefinition("Ed-Fi", "edfi"));

            var resourceModel = new ResourceModel(domainModelBuilder.Build());

            var resource = resourceModel.GetResourceByFullName(new FullName("schema1", "TestEntity1"));

            return(resource);
        }
コード例 #14
0
            private static DomainModelBuilder CreateFaultyDomainModel()
            {
                var entityDefinitions = new[]
                {
                    new EntityDefinition(
                        "schema1",
                        "CoreEntity",
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        new[]
                    {
                        new EntityIdentifierDefinition(
                            "PK",
                            new[]
                        {
                            "KeyProperty1", "KeyProperty2"
                        },
                            isPrimary: true)
                    },
                        true),
                    new EntityDefinition(
                        "schema1",
                        "Collection1Item",
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                        new EntityPropertyDefinition("KeyProperty2", new PropertyType(DbType.Int32), null, true)
                    },
                        new[]
                    {
                        new EntityIdentifierDefinition(
                            "PK",
                            new[]
                        {
                            "KeyProperty1", "KeyProperty2"
                        },
                            isPrimary: true)
                    },
                        true)
                };

                var associationDefinitions = new[]
                {
                    new AssociationDefinition(

                        //  The line that follows contains bad data
                        new FullName("UndefinedSchemaName", "FK_CoreEntityCollection"),
                        Cardinality.OneToZeroOrMore,
                        new FullName("schema1", "CoreEntity"),
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        new FullName("schema1", "Collection1Item"),
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        isIdentifying: true,
                        isRequired: true)
                };

                var aggredateDefinitions = new[]
                {
                    new AggregateDefinition(
                        new FullName("schema1", "CoreEntity"),
                        new[]
                    {
                        new FullName("schema1", "Collection1Item")
                    })
                };

                //  schema names do not match the names on the AggregateDefinition
                var schemaDefinition = new SchemaDefinition("logicalName", "schema1");

                var modelDefinitions = new DomainModelDefinitions(
                    schemaDefinition,
                    aggredateDefinitions,
                    entityDefinitions,
                    associationDefinitions);

                var domainModelDefinitionsProvider = MockRepository.GenerateStub <IDomainModelDefinitionsProvider>();

                domainModelDefinitionsProvider.Stub(x => x.GetDomainModelDefinitions())
                .Return(modelDefinitions);

                DomainModelBuilder builder = new DomainModelBuilder();

                builder.AddDomainModelDefinitionsList(
                    new List <DomainModelDefinitions>
                {
                    domainModelDefinitionsProvider.GetDomainModelDefinitions()
                });

                return(builder);
            }
コード例 #15
0
 protected override void Arrange()
 {
     domainModelBuilder = CreateFaultyDomainModel();
 }
コード例 #16
0
 protected override void Arrange()
 {
     domainModelBuilder = CreateValidDomainModel();
 }
コード例 #17
0
        private static Resource_Resource GetTestResource()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddSchema(new SchemaDefinition("schema1", "schema1"));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "TestEntity",
                    new[]
            {
                new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("KeyProperty2", new PropertyType(DbType.String), null, true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK",
                    new[]
                {
                    "KeyProperty1", "KeyProperty2"
                },
                    isPrimary: true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "TestEntity1",
                    new[]
            {
                new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("KeyProperty2", new PropertyType(DbType.String), null, true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK",
                    new[]
                {
                    "KeyProperty1", "KeyProperty2"
                },
                    isPrimary: true)
            }));

            //Setup TestEntity Reference
            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema1", "FK_TestEntity_TestEntity1"),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "TestEntity1"),
                    new[]
            {
                new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("KeyProperty2", new PropertyType(DbType.String), null, true)
            },
                    new FullName("schema1", "TestEntity"),
                    new[]
            {
                new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("KeyProperty2", new PropertyType(DbType.String), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "TestEntity"),
                    new[]
            {
                new FullName("schema1", "TestEntity")
            }));

            //Add aggregate for reference of TestEntity
            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "TestEntity1"),
                    new[]
            {
                new FullName("schema1", "TestEntity1")
            }));

            var resourceModel = new ResourceModel(domainModelBuilder.Build());

            var resource = resourceModel.GetResourceByFullName(new FullName("schema1", "TestEntity"));

            return(resource);
        }
コード例 #18
0
            private static DomainModelBuilder CreateValidDomainModel()
            {
                var entityDefinitions = new[]
                {
                    new EntityDefinition(
                        "schema1",
                        "CoreEntity",
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        new[]
                    {
                        new EntityIdentifierDefinition(
                            "PK",
                            new[]
                        {
                            "KeyProperty1", "KeyProperty2"
                        },
                            isPrimary: true)
                    },
                        true),
                    new EntityDefinition(
                        "schema1",
                        "Collection1Item",
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true),
                        new EntityPropertyDefinition("KeyProperty2", new PropertyType(DbType.Int32), null, true)
                    },
                        new[]
                    {
                        new EntityIdentifierDefinition(
                            "PK",
                            new[]
                        {
                            "KeyProperty1", "KeyProperty2"
                        },
                            isPrimary: true)
                    },
                        true)
                };

                var associationDefinitions = new[]
                {
                    new AssociationDefinition(
                        new FullName("schema1", "FK_CoreEntityCollection"),
                        Cardinality.OneToZeroOrMore,
                        new FullName("schema1", "CoreEntity"),
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        new FullName("schema1", "Collection1Item"),
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        isIdentifying: true,
                        isRequired: true)
                };

                var aggredateDefinitions = new[]
                {
                    new AggregateDefinition(
                        new FullName("schema1", "CoreEntity"),
                        new[]
                    {
                        new FullName("schema1", "Collection1Item")
                    })
                };

                // schema names do not match the names on the AggregateDefinition
                var schemaDefinition = new SchemaDefinition("logicalName", "schema1");

                var modelDefinitions = new DomainModelDefinitions(
                    schemaDefinition,
                    aggredateDefinitions,
                    entityDefinitions,
                    associationDefinitions);

                var domainModelDefinitionsProvider = A.Fake <IDomainModelDefinitionsProvider>();

                A.CallTo(() => domainModelDefinitionsProvider.GetDomainModelDefinitions())
                .Returns(modelDefinitions);

                DomainModelBuilder builder = new DomainModelBuilder();

                builder.AddDomainModelDefinitionsList(
                    new List <DomainModelDefinitions>
                {
                    domainModelDefinitionsProvider.GetDomainModelDefinitions()
                });

                return(builder);
            }
コード例 #19
0
        protected override void Act()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema", "AParent"),
                    new[]
            {
                new FullName("schema", "AnEntity")
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "AParent",
                    new[]
            {
                new EntityPropertyDefinition("Primary1", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_AnEntity",
                    new[]
                {
                    "Primary1"
                },
                    true)
            }));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema", "schema"),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema", "AParent"),
                    new[]
            {
                new EntityPropertyDefinition("Primary1", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new FullName("schema", "AnEntity"),
                    new[]
            {
                new EntityPropertyDefinition("Primary1", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    true,
                    true));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "AnEntity",
                    new[]
            {
                // Columns are defined deliberately out of order
                new EntityPropertyDefinition("Primary2", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Alternate2b", new PropertyType(DbType.String, 50), string.Empty, false),
                new EntityPropertyDefinition("Alternate1b", new PropertyType(DbType.String, 50), string.Empty, false),
                new EntityPropertyDefinition("Alternate1a", new PropertyType(DbType.String, 50), string.Empty, false),
                new EntityPropertyDefinition("Alternate2a", new PropertyType(DbType.String, 50), string.Empty, false),
                new EntityPropertyDefinition("Other", new PropertyType(DbType.String, 50), string.Empty, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_AnEntity",
                    new[]
                {
                    "Primary1", "Primary2"
                },
                    true),
                new EntityIdentifierDefinition(
                    "AK_AnEntity_1",
                    new[]
                {
                    "Alternate1a", "Alternate1b"
                },
                    false),
                new EntityIdentifierDefinition(
                    "AK_AnEntity_2",
                    new[]
                {
                    "Alternate2a", "Alternate2b"
                },
                    false)
            }));

            domainModelBuilder.AddSchema(new SchemaDefinition("schema", "schema"));

            var domainModel = domainModelBuilder.Build();

            _entity = domainModel.EntityByFullName[new FullName("schema", "AnEntity")];
        }
コード例 #20
0
        public void Should_return_the_correct_namespace_for_an_entity_and_an_extension_of_that_entity()
        {
            var domainModelBuilder = new DomainModelBuilder();

            var fullName            = new FullName("edfi", "TestEntity1");
            var fullName1           = new FullName("schema2", "TestEntity1Extension");
            var associationProperty = new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true);

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    fullName.Schema,
                    fullName.Name,
                    new[]
            {
                associationProperty,
                new EntityPropertyDefinition("StringProperty1", new PropertyType(DbType.String)),
                new EntityPropertyDefinition("DateProperty1", new PropertyType(DbType.Date))
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK",
                    new[]
                {
                    "KeyProperty1"
                },
                    isPrimary: true)
            }));

            domainModelBuilder.AddAggregate(new AggregateDefinition(fullName, new FullName[0]));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    fullName1.Schema,
                    fullName1.Name,
                    new[]
            {
                associationProperty,
                new EntityPropertyDefinition("StringProperty1", new PropertyType(DbType.String)),
                new EntityPropertyDefinition("DateProperty1", new PropertyType(DbType.Date))
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK",
                    new[]
                {
                    "KeyProperty1"
                },
                    isPrimary: true)
            }));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema2", "FromCore"),
                    Cardinality.OneToOneExtension,
                    fullName,
                    new[]
            {
                associationProperty
            },
                    fullName1,
                    new[]
            {
                associationProperty
            },
                    true,
                    true));

            domainModelBuilder.AddSchema(new SchemaDefinition("EdFi", fullName.Schema));
            domainModelBuilder.AddSchema(new SchemaDefinition("schema2", "schema2"));

            var domainModel = domainModelBuilder.Build();

            string entityNamespace = domainModel.EntityByFullName[fullName]
                                     .AggregateNamespace(EdFiConventions.ProperCaseName);

            string entityName = domainModel.EntityByFullName[fullName]
                                .Name;

            string entityExtensionNamespace = domainModel.EntityByFullName[fullName1]
                                              .AggregateNamespace("TestEntity1ExtensionProperCaseName");

            string entityExtensionName = domainModel.EntityByFullName[fullName1]
                                         .Name;

            Assert.That(
                entityNamespace.Equals($"{Namespaces.Entities.NHibernate.BaseNamespace}.{entityName}Aggregate.{EdFiConventions.ProperCaseName}"));

            Assert.That(
                entityExtensionNamespace.Equals(
                    $"{Namespaces.Entities.NHibernate.BaseNamespace}.{entityName}Aggregate.TestEntity1ExtensionProperCaseName"));
        }
コード例 #21
0
        public static DomainModel GetTestDomainModel()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "Student"),
                    new[]
            {
                new FullName("schema1", "Student"), new FullName("schema1", "StudentAddress"), new FullName("schema1", "StudentLearningStyle")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "EducationOrganization"),
                    new[]
            {
                new FullName("schema1", "EducationOrganizationAddress")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "School"),
                    new[]
            {
                new FullName("schema1", "School"), new FullName("schema1", "SchoolCategory")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "SchoolCategoryType"),
                    new[]
            {
                new FullName("schema1", "SchoolCategoryType")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "StudentSchoolAssociation"),
                    new[]
            {
                new FullName("schema1", "StudentSchoolAssociation")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "SchoolType"),
                    new[]
            {
                new FullName("schema1", "SchoolType")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "StudentProgramAssociation"),
                    new[]
            {
                new FullName("schema1", "StudentProgramAssociation")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema1", "StudentCTEProgramAssociation"),
                    new[]
            {
                new FullName("schema1", "StudentCTEProgramAssociation")
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "Student",
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("FirstName", new PropertyType(DbType.String), null, false),
                new EntityPropertyDefinition("LastSurname", new PropertyType(DbType.String), null, false),
                new EntityPropertyDefinition("StudentUniqueId", new PropertyType(DbType.String), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_Student",
                    new[]
                {
                    "StudentUSI"
                },
                    true),
                new EntityIdentifierDefinition(
                    "AK_Student_StudentUniqueId",
                    new[]
                {
                    "StudentUniqueId"
                },
                    false)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "StudentAddress",
                    new[]
            {
                new EntityPropertyDefinition("City", new PropertyType(DbType.String), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentAddress",
                    new[]
                {
                    "StudentUSI", "AddressTypeId"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "StudentLearningStyle",
                    new[]
            {
                new EntityPropertyDefinition("VisualLearning", new PropertyType(DbType.Decimal), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentLearningStyle",
                    new[]
                {
                    "StudentUSI"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "EducationOrganization",
                    new[]
            {
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("NameOfInstitution", new PropertyType(DbType.String), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_EducationOrganization",
                    new[]
                {
                    "EducationOrganizationId"
                },
                    true)
            },
                    isAbstract: true));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "EducationOrganizationAddress",
                    new[]
            {
                new EntityPropertyDefinition("City", new PropertyType(DbType.String), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_EducationOrganizationAddress",
                    new[]
                {
                    "EducationOrganizationId", "AddressTypeId"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "School",
                    new EntityPropertyDefinition[0],
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_School",
                    new[]
                {
                    "SchoolId"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "SchoolCategory",
                    new EntityPropertyDefinition[0],
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_SchoolCategory",
                    new[]
                {
                    "SchoolId", "SchoolCategoryTypeId"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "SchoolCategoryType",
                    new[]
            {
                new EntityPropertyDefinition("SchoolCategoryTypeId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ShortDescription", new PropertyType(DbType.String), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_SchoolCategoryType",
                    new[]
                {
                    "SchoolCategoryTypeId"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "StudentSchoolAssociation",
                    new[]
            {
                new EntityPropertyDefinition("EntryDate", new PropertyType(DbType.DateTime), null, true),
                new EntityPropertyDefinition("ExitWithdrawDate", new PropertyType(DbType.DateTime), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentSchoolAssociation",
                    new[]
                {
                    "StudentUSI", "SchoolId", "EntryDate"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "SchoolType",
                    new[]
            {
                new EntityPropertyDefinition("SchoolTypeId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ShortDescription", new PropertyType(DbType.String), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_SchoolType",
                    new[]
                {
                    "SchoolTypeId"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "StudentProgramAssociation",
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ProgramTypeId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ProgramName", new PropertyType(DbType.String), null, true),
                new EntityPropertyDefinition("ProgramEducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("BeginDate", new PropertyType(DbType.DateTime), null, true),
                new EntityPropertyDefinition("EndDate", new PropertyType(DbType.DateTime), null, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentProgramAssociation",
                    new[]
                {
                    "StudentUSI", "EducationOrganizationId", "ProgramTypeId", "ProgramName", "ProgramEducationOrganizationId", "BeginDate"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema1",
                    "StudentCTEProgramAssociation",
                    new EntityPropertyDefinition[0],
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentCTEProgramAssociation",
                    new[]
                {
                    "StudentUSI", "EducationOrganizationId", "ProgramTypeId", "ProgramName", "ProgramEducationOrganizationId", "BeginDate"
                },
                    true)
            }));

            // Add associations
            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "SchoolType"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolTypeId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolTypeId", new PropertyType(DbType.Int32), null, true)
            },
                    false,
                    false));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToOne,
                    new FullName("schema1", "Student"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "StudentLearningStyle"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "Student"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "StudentAddress"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "EducationOrganization"),
                    new[]
            {
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "EducationOrganizationAddress"),
                    new[]
            {
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToOneInheritance,
                    new FullName("schema1", "EducationOrganization"),
                    new[]
            {
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "SchoolCategory"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            // Add a fictitious self-recursive relationship
            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "School"),
                    new[]
            {
                new EntityPropertyDefinition("ParentSchoolId", new PropertyType(DbType.Int32), null, false)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "SchoolCategoryType"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolCategoryTypeId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "SchoolCategory"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolCategoryTypeId", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "Student"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "StudentSchoolAssociation"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema1", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, true)
            },
                    new FullName("schema1", "StudentSchoolAssociation"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, true)
            },
                    true,
                    true));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName(
                        "schema1",
                        Guid.NewGuid()
                        .ToString()),
                    Cardinality.OneToOneInheritance,
                    new FullName("schema1", "StudentProgramAssociation"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ProgramTypeId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ProgramName", new PropertyType(DbType.String), null, true),
                new EntityPropertyDefinition("ProgramEducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("BeginDate", new PropertyType(DbType.DateTime), null, true),
            },
                    new FullName("schema1", "StudentCTEProgramAssociation"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("EducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ProgramTypeId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("ProgramName", new PropertyType(DbType.String), null, true),
                new EntityPropertyDefinition("ProgramEducationOrganizationId", new PropertyType(DbType.Int32), null, true),
                new EntityPropertyDefinition("BeginDate", new PropertyType(DbType.DateTime), null, true),
            },
                    true,
                    true));

            domainModelBuilder.AddSchema(new SchemaDefinition("schema1", "schema1"));

            return(domainModelBuilder.Build());
        }
コード例 #22
0
            private static DomainModelBuilder CreateFaultyDomainModel()
            {
                var entityDefinitions = new[]
                {
                    new EntityDefinition(
                        "DefinedSchema",
                        "RootEntity",
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        new[]
                    {
                        new EntityIdentifierDefinition(
                            "PK",
                            new[]
                        {
                            "KeyProperty1", "KeyProperty2"
                        },
                            isPrimary: true)
                    },
                        true),

                    // The line that follows is causing the failure.  The 1st value should be "schema1", not "schema2"
                    new EntityDefinition(
                        "UndefinedSchema",
                        "ChildEntity",
                        new[]
                    {
                        new EntityPropertyDefinition("KeyProperty1", new PropertyType(DbType.Int32), null, true)
                    },
                        new[]
                    {
                        new EntityIdentifierDefinition(
                            "PK",
                            new[]
                        {
                            "KeyProperty1", "KeyProperty2"
                        },
                            isPrimary: true)
                    },
                        true)
                };

                var associationDefinitions = new AssociationDefinition[0];

                var aggregateDefinitions = new[]
                {
                    new AggregateDefinition(
                        new FullName("DefinedSchema", "RootEntity"),
                        new[]
                    {
                        new FullName("UndefinedSchema", "ChildEntity")
                    })
                };

                var schemaDefinition = new SchemaDefinition("logicalName", "DefinedSchema");

                var modelDefinitions = new DomainModelDefinitions(
                    schemaDefinition,
                    aggregateDefinitions,
                    entityDefinitions,
                    associationDefinitions);

                var domainModelDefinitionsProvider = A.Fake <IDomainModelDefinitionsProvider>();

                A.CallTo(() => domainModelDefinitionsProvider.GetDomainModelDefinitions())
                .Returns(modelDefinitions);

                DomainModelBuilder builder = new DomainModelBuilder();

                builder.AddDomainModelDefinitionsList(
                    new List <DomainModelDefinitions>
                {
                    domainModelDefinitionsProvider.GetDomainModelDefinitions()
                });

                return(builder);
            }
コード例 #23
0
        public void SetUp()
        {
            CountryTestDescriptor1 = new CountryDescriptor
            {
                Namespace          = "uri://namespace1/CountryDescriptor",
                CodeValue          = "Test Country Descriptor 1",
                ShortDescription   = "Test Country Descriptor 1",
                Description        = "Test Country Descriptor 1",
                EffectiveBeginDate = DateTime.Now
            };

            CountryTestDescriptor2 = new CountryDescriptor
            {
                Namespace          = "uri://namespace1/CountryDescriptor",
                CodeValue          = "Test Country Descriptor 2",
                ShortDescription   = "Test Country Descriptor 2",
                Description        = "Test Country Descriptor 2",
                EffectiveBeginDate = DateTime.Now
            };

            CountryTestDescriptor3 = new CountryDescriptor
            {
                Namespace          = "uri://namespace2/CountryDescriptor",
                CodeValue          = "Test Country Descriptor 1",
                ShortDescription   = "Test Country Descriptor 1",
                Description        = "Test Country Descriptor 1",
                EffectiveBeginDate = DateTime.Now
            };

            AssessmentPeriodTestDescriptor1 = new AssessmentPeriodDescriptor
            {
                Namespace          = "uri://namespace1/AssessmentPeriodDescriptor",
                CodeValue          = "Test Assessment Period Descriptor 1",
                ShortDescription   = "Test Assessment Period Descriptor 1",
                Description        = "Test Assessment Period Descriptor 1",
                EffectiveBeginDate = DateTime.Now
            };

            using (var session = SessionFactory.OpenSession())
            {
                session.Save(CountryTestDescriptor1);
                session.Save(CountryTestDescriptor2);
                session.Save(CountryTestDescriptor3);
                session.Save(AssessmentPeriodTestDescriptor1);
            }

            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddSchema(new SchemaDefinition("Ed-Fi", "edfi"));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("edfi", "AssessmentPeriodDescriptor"),
                    new FullName[] { }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "edfi",
                    "AssessmentPeriodDescriptor",
                    new EntityPropertyDefinition[] { },
                    new EntityIdentifierDefinition[] { }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("edfi", "CountryDescriptor"),
                    new FullName[] { }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "edfi",
                    "CountryDescriptor",
                    new EntityPropertyDefinition[] { },
                    new EntityIdentifierDefinition[] { }));

            var domainModelProvider = MockRepository.GenerateMock <IDomainModelProvider>();

            domainModelProvider.Stub(x => x.GetDomainModel())
            .Return(domainModelBuilder.Build());

            DescriptorLookupProvider = new DescriptorLookupProvider(
                SessionFactory, new EdFiDescriptorReflectionProvider(domainModelProvider));
        }
コード例 #24
0
        protected override void Act()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema", "AParent"),
                    new[]
            {
                new FullName("schema", "AChild")
            }));

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema", "AParent2"),
                    new FullName[0]));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "AParent",
                    new[]
            {
                new EntityPropertyDefinition("Primary1a", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Primary1b", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_AParent",
                    new[]
                {
                    "Primary1a", "Primary1b"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "AChild",
                    new[]
            {
                new EntityPropertyDefinition("ChildProperty1", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("ChildProperty2", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_AChild",
                    new[]
                {
                    "Primary1a", "Primary1b", "Primary2"
                },
                    true)
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "AParent2",
                    new[]
            {
                new EntityPropertyDefinition("Primary1b", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Primary2", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_AParent2",
                    new[]
                {
                    "Primary2", "Primary1b"
                },
                    true)
            }));

            // Add non-parent identifying association first so that the Primary1b property is used in the target entity.
            var unifyingNonParentAssociationFqn = new FullName("schema", "AParent2AChild");

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    unifyingNonParentAssociationFqn,
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema", "AParent2"),
                    new[]
            {
                new EntityPropertyDefinition("Primary1b", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Primary2", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new FullName("schema", "AChild"),
                    new[]
            {
                new EntityPropertyDefinition("Primary1b", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Primary2", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    true,
                    true));

            // Add parent identifying association second so that the Primary1b property is NOT used in the target entity.
            var oneToManyAssociationFqn = new FullName("schema", "AParent2AChild2");

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    oneToManyAssociationFqn,
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema", "AParent"),
                    new[]
            {
                new EntityPropertyDefinition("Primary1a", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Primary1b", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    new FullName("schema", "AChild"),
                    new[]
            {
                new EntityPropertyDefinition("Primary1a", new PropertyType(DbType.Int32), string.Empty, true),
                new EntityPropertyDefinition("Primary1b", new PropertyType(DbType.Int32), string.Empty, true)
            },
                    true,
                    true));

            domainModelBuilder.AddSchema(new SchemaDefinition("schema", "schema"));

            var model = domainModelBuilder.Build();

            _childEntity = model.EntityByFullName[new FullName("schema", "AChild")];

            _unifyingNonParentAssociation = model.AssociationByFullName[unifyingNonParentAssociationFqn];
            _parentOneToManyAssociation   = model.AssociationByFullName[oneToManyAssociationFqn];
        }
コード例 #25
0
        protected override void Act()
        {
            var domainModelBuilder = new DomainModelBuilder();

            domainModelBuilder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema", "Parent"),
                    new[]
            {
                new FullName("schema", "Child")
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "Parent",
                    new[]
            {
                new EntityPropertyDefinition("ParentId", new PropertyType(DbType.Int32), null, isIdentifying: true)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_Parent",
                    new[]
                {
                    "ParentId"
                })
            }));

            domainModelBuilder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "Child",
                    new[]
            {
                new EntityPropertyDefinition("ChildId", new PropertyType(DbType.Int32), null)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_Child",
                    new[]
                {
                    "ChildId"
                })
            }));

            domainModelBuilder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema", "FK_Test"),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema", "Parent"),
                    new[]
            {
                new EntityPropertyDefinition("ParentId", new PropertyType(DbType.Int32), null)
            },
                    new FullName("schema", "Child"),
                    new[]
            {
                new EntityPropertyDefinition("ParentId", new PropertyType(DbType.Int32), null)
            },
                    isIdentifying: false,
                    isRequired: true));

            domainModelBuilder.AddSchema(new SchemaDefinition("schema", "schema"));

            _domainModel = domainModelBuilder.Build();
        }
コード例 #26
0
        protected override void Act()
        {
            var builder = new DomainModelBuilder();

            builder.AddAggregate(
                new AggregateDefinition(
                    new FullName("edfi", "Student"),
                    new[]
            {
                new FullName("edfi", "Student")
            }));

            // Top-level
            builder.AddEntity(
                new EntityDefinition(
                    "edfi",
                    "Student",
                    new[]
            {
                new EntityPropertyDefinition(
                    "StudentUSI",
                    new PropertyType(DbType.Int32, 0, 10, 0, false),
                    "A unique number or alphanumeric code assigned to a student by a state education agency.",
                    true,
                    true),
                new EntityPropertyDefinition(
                    "FirstName",
                    new PropertyType(DbType.String, 75, 0, 0, false),
                    "A name given to an individual at birth, baptism, or during another naming ceremony, or through legal change.",
                    false,
                    false),
                new EntityPropertyDefinition(
                    "MiddleName",
                    new PropertyType(DbType.String, 75, 0, 0, true),
                    "A secondary name given to an individual at birth, baptism, or during another naming ceremony.",
                    false,
                    false),
                new EntityPropertyDefinition(
                    "LastSurname",
                    new PropertyType(DbType.String, 75, 0, 0, false),
                    "The name borne in common by members of a family.",
                    false,
                    false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_Student",
                    new[]
                {
                    "StudentUSI"
                },
                    true,
                    false)
            },
                    isAbstract: true));

            builder.AddEntity(
                new EntityDefinition(
                    "sample",
                    "StudentPet",
                    new[]
            {
                new EntityPropertyDefinition("PetName", new PropertyType(DbType.String, 20, 0, 0, false), "", true, false),
                new EntityPropertyDefinition("IsFixed", new PropertyType(DbType.Boolean, 0, 0, 0, true), "", false, false),
                new EntityPropertyDefinition("CreateDate", new PropertyType(DbType.DateTime, 0, 0, 0, false), "", false, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentPet",
                    new[]
                {
                    "StudentUSI", "PetName"
                },
                    true,
                    false)
            },
                    false,
                    "")
                );

            builder.AddEntity(
                new EntityDefinition(
                    "sample",
                    "StudentPetPreference",
                    new[]
            {
                new EntityPropertyDefinition("MinimumWeight", new PropertyType(DbType.Int32, 0, 10, 0, false), "", false, false),
                new EntityPropertyDefinition("MaximumWeight", new PropertyType(DbType.Int32, 0, 10, 0, false), "", false, false),
                new EntityPropertyDefinition("CreateDate", new PropertyType(DbType.DateTime, 0, 0, 0, false), "", false, false)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_StudentPetPreference",
                    new[]
                {
                    "StudentUSI"
                },
                    true,
                    false)
            },
                    false,
                    "")
                );

            builder.AddAssociation(
                new AssociationDefinition(
                    new FullName("sample", "FK_StudentPet_Student_StudentUSI"),
                    Cardinality.OneToZeroOrMore,
                    new FullName("edfi", "Student"),
                    new[]
            {
                new EntityPropertyDefinition(
                    "StudentUSI",
                    new PropertyType(DbType.Int32, 0, 10, 0, false),
                    "A unique number or alphanumeric code assigned to a student by a state education agency.",
                    true,
                    true)
            },
                    new FullName("sample", "StudentPet"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32, 0, 10, 0, false), "", true, false)
            },
                    true,
                    true)
                );

            builder.AddAssociation(
                new AssociationDefinition(
                    new FullName("sample", "FK_StudentPetPreference_Student_StudentUSI"),
                    Cardinality.OneToOne,
                    new FullName("edfi", "Student"),
                    new[]
            {
                new EntityPropertyDefinition(
                    "StudentUSI",
                    new PropertyType(DbType.Int32, 0, 10, 0, false),
                    "A unique number or alphanumeric code assigned to a student by a state education agency.",
                    true,
                    true)
            },
                    new FullName("sample", "StudentPetPreference"),
                    new[]
            {
                new EntityPropertyDefinition("StudentUSI", new PropertyType(DbType.Int32, 0, 10, 0, false), "", true, true)
            },
                    true,
                    true)
                );

            builder.AddAggregateExtension(
                new AggregateExtensionDefinition(
                    new FullName("edfi", "Student"),
                    new[]
            {
                new FullName("sample", "StudentPet"), new FullName("sample", "StudentPetPreference")
            })
                );

            builder.AddSchema(new SchemaDefinition("Ed-Fi", "edfi"));
            builder.AddSchema(new SchemaDefinition("Sample", "sample"));

            _domainModel = builder.Build();

            _resourceModel = new ResourceModel(_domainModel);
        }
コード例 #27
0
        protected override void Act()
        {
            var builder = new DomainModelBuilder();

            builder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema", "EdOrg"),
                    new[]
            {
                new FullName("schema", "EdOrgAddress")
            }));

            builder.AddAggregate(
                new AggregateDefinition(
                    new FullName("schema", "School"),
                    new[]
            {
                new FullName("schema", "SchoolCategory")
            }));

            builder.AddAggregate(new AggregateDefinition(new FullName("schema", "SpecializedSchool"), new FullName[0]));

            // Top-level
            builder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "EdOrg",
                    new[]
            {
                new EntityPropertyDefinition("EdOrgId", new PropertyType(DbType.Int32), null, isIdentifying: true),
                new EntityPropertyDefinition("NameOfInstitution", new PropertyType(DbType.String, 30), null)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_EdOrg",
                    new[]
                {
                    "EdOrgId"
                },
                    isPrimary: true)
            },
                    isAbstract: true));

            builder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "EdOrgAddress",
                    new[]
            {
                new EntityPropertyDefinition("AddressTypeId", new PropertyType(DbType.Int32), null, isIdentifying: true),
                new EntityPropertyDefinition("City", new PropertyType(DbType.String, 30), null)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_EdOrgAddress",
                    new[]
                {
                    "EdOrgId", "AddressTypeId"
                },
                    isPrimary: true)
            }));

            builder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema", "FK_EdOrgAddress_EdOrg"),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema", "EdOrg"),
                    new[]
            {
                new EntityPropertyDefinition("EdOrgId", new PropertyType(DbType.Int32), null, isIdentifying: true)
            },
                    new FullName("schema", "EdOrgAddress"),
                    new[]
            {
                new EntityPropertyDefinition("EdOrgId", new PropertyType(DbType.Int32), null)
            },
                    isIdentifying: true,
                    isRequired: true));

            // Middle-level
            builder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "School",
                    new[]
            {
                new EntityPropertyDefinition("SchoolThing", new PropertyType(DbType.String, 30), null)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_School",
                    new[]
                {
                    "SchoolId"
                },
                    isPrimary: true)
            },
                    isAbstract: true));

            builder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "SchoolCategory",
                    new[]
            {
                new EntityPropertyDefinition("CategoryTypeId", new PropertyType(DbType.Int32), null, isIdentifying: true),
                new EntityPropertyDefinition("CategoryName", new PropertyType(DbType.String, 30), null)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_SchoolCategory",
                    new[]
                {
                    "SchoolId", "CategoryTypeId"
                },
                    isPrimary: true)
            }));

            builder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema", "FK_SchoolCategory_School"),
                    Cardinality.OneToZeroOrMore,
                    new FullName("schema", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, isIdentifying: true)
            },
                    new FullName("schema", "SchoolCategory"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null)
            },
                    isIdentifying: true,
                    isRequired: true));

            builder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema", "FK_School_EdOrg"),
                    Cardinality.OneToOneInheritance,
                    new FullName("schema", "EdOrg"),
                    new[]
            {
                new EntityPropertyDefinition("EdOrgId", new PropertyType(DbType.Int32), null, isIdentifying: true)
            },
                    new FullName("schema", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null)
            },
                    isIdentifying: true,
                    isRequired: true));

            // Lower level
            builder.AddEntity(
                new EntityDefinition(
                    "schema",
                    "SpecializedSchool",
                    new[]
            {
                new EntityPropertyDefinition("SpecializedSchoolThing", new PropertyType(DbType.String, 30), null)
            },
                    new[]
            {
                new EntityIdentifierDefinition(
                    "PK_School",
                    new[]
                {
                    "SpecializedSchoolId"
                },
                    isPrimary: true)
            },
                    isAbstract: true));

            builder.AddAssociation(
                new AssociationDefinition(
                    new FullName("schema", "FK_SpecializedSchool_School"),
                    Cardinality.OneToOneInheritance,
                    new FullName("schema", "School"),
                    new[]
            {
                new EntityPropertyDefinition("SchoolId", new PropertyType(DbType.Int32), null, isIdentifying: true)
            },
                    new FullName("schema", "SpecializedSchool"),
                    new[]
            {
                new EntityPropertyDefinition("SpecializedSchoolId", new PropertyType(DbType.Int32), null)
            },
                    isIdentifying: true,
                    isRequired: true));

            builder.AddSchema(new SchemaDefinition("schema", "schema"));

            _domainModel = builder.Build();

            _resourceModel = new ResourceModel(_domainModel);
        }
コード例 #28
0
            protected override void Arrange()
            {
                DomainModelBuilder builder = new DomainModelBuilder();

                var edfiSchemaDefinition = new SchemaDefinition(
                    EdFiConventions.LogicalName,
                    EdFiConventions.PhysicalSchemaName);

                var extensionSchemaDefinition = new SchemaDefinition(
                    "ExtensionLogicalName",
                    "ExtensionPhysicalSchemaName");

                builder.AddSchema(edfiSchemaDefinition);
                builder.AddSchema(extensionSchemaDefinition);

                builder.AddAggregate(
                    new AggregateDefinition(
                        new FullName(edfiSchemaDefinition.PhysicalName, "EdFiEntity"),
                        new[]
                {
                    new FullName(extensionSchemaDefinition.PhysicalName, "AggregateExtensionEntity")
                }));

                builder.AddEntity(
                    new EntityDefinition(
                        edfiSchemaDefinition.PhysicalName,
                        "EdFiEntity",
                        new[]
                {
                    new EntityPropertyDefinition(
                        "USI",
                        new PropertyType(DbType.Int32, 0, 10, 0, false),
                        "EdFiEntity Identity Column",
                        true,
                        true)
                },
                        new EntityIdentifierDefinition[]
                        { }));

                builder.AddEntity(
                    new EntityDefinition(
                        extensionSchemaDefinition.PhysicalName,
                        "AggregateExtensionEntity",
                        new EntityPropertyDefinition[]
                        { },
                        new EntityIdentifierDefinition[]
                        { }));

                var associationDefinition =
                    new AssociationDefinition(
                        new FullName(extensionSchemaDefinition.PhysicalName, "FK_AggregateExtensionEntity_EdFiEntity_USI"),
                        Cardinality.OneToZeroOrMore,
                        new FullName(edfiSchemaDefinition.PhysicalName, "EdFiEntity"),
                        new[]
                {
                    new EntityPropertyDefinition(
                        "USI",
                        new PropertyType(DbType.Int32, 0, 10, 0, false),
                        "EdFiEntity Identity Column",
                        true,
                        true)
                },
                        new FullName(extensionSchemaDefinition.PhysicalName, "AggregateExtensionEntity"),
                        new[]
                {
                    new EntityPropertyDefinition(
                        "USI",
                        new PropertyType(DbType.Int32, 0, 10, 0, false),
                        "",
                        true,
                        false)
                },
                        true,
                        true);

                builder.AddAssociation(associationDefinition);

                var domainModel = builder.Build();

                _aggregateExtensionEntity =
                    domainModel.Entities.FirstOrDefault(e => e.Name == "AggregateExtensionEntity");
            }