コード例 #1
0
        public NonPrimitiveTypeRoundtripAtomTests()
        {
            this.model = new EdmModel();

            EdmComplexType personalInfo = new EdmComplexType(MyNameSpace, "PersonalInfo");
            personalInfo.AddStructuralProperty("Age", EdmPrimitiveTypeKind.Int16);
            personalInfo.AddStructuralProperty("Email", EdmPrimitiveTypeKind.String);
            personalInfo.AddStructuralProperty("Tel", EdmPrimitiveTypeKind.String);
            personalInfo.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Guid);
            
            EdmComplexType subjectInfo = new EdmComplexType(MyNameSpace, "Subject");
            subjectInfo.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            subjectInfo.AddStructuralProperty("Score", EdmPrimitiveTypeKind.Int16);

            EdmCollectionTypeReference subjectsCollection = new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(subjectInfo, isNullable:true)));

            EdmEntityType studentInfo = new EdmEntityType(MyNameSpace, "Student");
            studentInfo.AddStructuralProperty("Info", new EdmComplexTypeReference(personalInfo, isNullable: false));
            studentInfo.AddProperty(new EdmStructuralProperty(studentInfo, "Subjects", subjectsCollection));

            EdmCollectionTypeReference hobbiesCollection = new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: false)));
            studentInfo.AddProperty(new EdmStructuralProperty(studentInfo, "Hobbies", hobbiesCollection));

            model.AddElement(studentInfo);
            model.AddElement(personalInfo);
            model.AddElement(subjectInfo);
        }
コード例 #2
0
        public void Initialize()
        {
            this.model = new EdmModel();

            EdmComplexType personalInfo = new EdmComplexType(MyNameSpace, "PersonalInfo");
            personalInfo.AddStructuralProperty("Age", EdmPrimitiveTypeKind.Int16);
            personalInfo.AddStructuralProperty("Email", EdmPrimitiveTypeKind.String);
            personalInfo.AddStructuralProperty("Tel", EdmPrimitiveTypeKind.String);
            personalInfo.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Guid);

            EdmComplexType derivedPersonalInfo = new EdmComplexType(MyNameSpace, "DerivedPersonalInfo", personalInfo);
            derivedPersonalInfo.AddStructuralProperty("Hobby", EdmPrimitiveTypeKind.String);

            EdmComplexType derivedDerivedPersonalInfo = new EdmComplexType(MyNameSpace, "DerivedDerivedPersonalInfo", derivedPersonalInfo);
            derivedDerivedPersonalInfo.AddStructuralProperty("Education", EdmPrimitiveTypeKind.String);

            EdmComplexType subjectInfo = new EdmComplexType(MyNameSpace, "Subject");
            subjectInfo.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            subjectInfo.AddStructuralProperty("Score", EdmPrimitiveTypeKind.Int16);

            EdmComplexType derivedSubjectInfo = new EdmComplexType(MyNameSpace, "DerivedSubject", subjectInfo);
            derivedSubjectInfo.AddStructuralProperty("Teacher", EdmPrimitiveTypeKind.String);

            EdmComplexType derivedDerivedSubjectInfo = new EdmComplexType(MyNameSpace, "DerivedDerivedSubject", derivedSubjectInfo);
            derivedDerivedSubjectInfo.AddStructuralProperty("Classroom", EdmPrimitiveTypeKind.String);

            EdmCollectionTypeReference subjectsCollection = new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(subjectInfo, isNullable: true)));

            studentInfo = new EdmEntityType(MyNameSpace, "Student");
            studentInfo.AddStructuralProperty("Info", new EdmComplexTypeReference(personalInfo, isNullable: false));
            studentInfo.AddProperty(new EdmStructuralProperty(studentInfo, "Subjects", subjectsCollection));

            // enum with flags
            var enumFlagsType = new EdmEnumType(MyNameSpace, "ColorFlags", isFlags: true);
            enumFlagsType.AddMember("Red", new EdmIntegerConstant(1));
            enumFlagsType.AddMember("Green", new EdmIntegerConstant(2));
            enumFlagsType.AddMember("Blue", new EdmIntegerConstant(4));
            studentInfo.AddStructuralProperty("ClothesColors", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEnumTypeReference(enumFlagsType, true))));

            EdmCollectionTypeReference hobbiesCollection = new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: false)));
            studentInfo.AddProperty(new EdmStructuralProperty(studentInfo, "Hobbies", hobbiesCollection));

            model.AddElement(enumFlagsType);
            model.AddElement(studentInfo);
            model.AddElement(personalInfo);
            model.AddElement(derivedPersonalInfo);
            model.AddElement(derivedDerivedPersonalInfo);
            model.AddElement(subjectInfo);
            model.AddElement(derivedSubjectInfo);
            model.AddElement(derivedDerivedSubjectInfo);

            IEdmEntityContainer defaultContainer = new EdmEntityContainer("NS", "DefaultContainer");
            model.AddElement(defaultContainer);

            this.studentSet = new EdmEntitySet(defaultContainer, "MySet", this.studentInfo);
        }
コード例 #3
0
        public static IEdmModel CreateServiceEdmModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "PerfInMemoryContainer");
            model.AddElement(defaultContainer);

            var personType = new EdmEntityType(ns, "Person");
            var personIdProperty = new EdmStructuralProperty(personType, "PersonID", EdmCoreModel.Instance.GetInt32(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
            personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "MiddleName", EdmCoreModel.Instance.GetString(true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Age", EdmCoreModel.Instance.GetInt32(false)));
            model.AddElement(personType);

            var simplePersonSet = new EdmEntitySet(defaultContainer, "SimplePeopleSet", personType);
            defaultContainer.AddElement(simplePersonSet);

            var largetPersonSet = new EdmEntitySet(defaultContainer, "LargePeopleSet", personType);
            defaultContainer.AddElement(largetPersonSet);

            var addressType = new EdmComplexType(ns, "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "PostalCode", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(addressType);

            var companyType = new EdmEntityType(ns, "Company");
            var companyId = new EdmStructuralProperty(companyType, "CompanyID", EdmCoreModel.Instance.GetInt32(false));
            companyType.AddProperty(companyId);
            companyType.AddKeys(companyId);
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Name", EdmCoreModel.Instance.GetString(true)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Address", new EdmComplexTypeReference(addressType, true)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Revenue", EdmCoreModel.Instance.GetInt32(false)));

            model.AddElement(companyType);

            var companySet = new EdmEntitySet(defaultContainer, "CompanySet", companyType);
            defaultContainer.AddElement(companySet);

            var companyEmployeeNavigation = companyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Employees",
                Target = personType,
                TargetMultiplicity = EdmMultiplicity.Many
            });
            companySet.AddNavigationTarget(companyEmployeeNavigation, largetPersonSet);

            // ResetDataSource
            var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
            model.AddElement(resetDataSourceAction);
            defaultContainer.AddActionImport(resetDataSourceAction);

            return model;
        }
コード例 #4
0
        public static IEdmModel CreateModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "DefaultContainer");
            model.AddElement(defaultContainer);

            var addressType = new EdmComplexType(ns, "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Road", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(addressType);

            var personType = new EdmEntityType(ns, "Person");
            var personIdProperty = new EdmStructuralProperty(personType, "PersonId", EdmCoreModel.Instance.GetInt32(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
            personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Address", new EdmComplexTypeReference(addressType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Descriptions", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));

            model.AddElement(personType);
            var peopleSet = new EdmEntitySet(defaultContainer, "People", personType);
            defaultContainer.AddElement(peopleSet);

            var numberComboType = new EdmComplexType(ns, "NumberCombo");
            numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Small", EdmCoreModel.Instance.GetInt32(false)));
            numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Middle", EdmCoreModel.Instance.GetInt64(false)));
            numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Large", EdmCoreModel.Instance.GetDecimal(false)));
            model.AddElement(numberComboType);

            var productType = new EdmEntityType(ns, "Product");
            var productIdProperty = new EdmStructuralProperty(productType, "ProductId", EdmCoreModel.Instance.GetInt32(false));
            productType.AddProperty(productIdProperty);
            productType.AddKeys(new IEdmStructuralProperty[] { productIdProperty });
            productType.AddProperty(new EdmStructuralProperty(productType, "Quantity", EdmCoreModel.Instance.GetInt64(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "LifeTimeInSeconds", EdmCoreModel.Instance.GetDecimal(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "TheCombo", new EdmComplexTypeReference(numberComboType, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "LargeNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDecimal(false)))));

            model.AddElement(productType);
            var productsSet = new EdmEntitySet(defaultContainer, "Products", productType);
            defaultContainer.AddElement(productsSet);

            var productsProperty = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Products",
                Target = productType,
                TargetMultiplicity = EdmMultiplicity.Many
            });
            peopleSet.AddNavigationTarget(productsProperty, productsSet);

            IEnumerable<EdmError> errors;
            model.Validate(out errors);

            return model;
        }
コード例 #5
0
        static InstanceAnnotationsReaderIntegrationTests()
        {
            EdmModel modelTmp = new EdmModel();
            EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
            modelTmp.AddElement(EntityType);

            var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
            EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
            EntityType.AddProperty(keyProperty);
            var resourceNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
            var resourceSetNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceSetNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.Many });

            var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer_sub");
            modelTmp.AddElement(defaultContainer);
            EntitySet = new EdmEntitySet(defaultContainer, "TestEntitySet", EntityType);
            EntitySet.AddNavigationTarget(resourceNavigationProperty, EntitySet);
            EntitySet.AddNavigationTarget(resourceSetNavigationProperty, EntitySet);
            defaultContainer.AddElement(EntitySet);

            Singleton = new EdmSingleton(defaultContainer, "TestSingleton", EntityType);
            Singleton.AddNavigationTarget(resourceNavigationProperty, EntitySet);
            Singleton.AddNavigationTarget(resourceSetNavigationProperty, EntitySet);
            defaultContainer.AddElement(Singleton);

            ComplexType = new EdmComplexType("TestNamespace", "TestComplexType");
            ComplexType.AddProperty(new EdmStructuralProperty(ComplexType, "StringProperty", EdmCoreModel.Instance.GetString(false)));
            modelTmp.AddElement(ComplexType);

            Model = TestUtils.WrapReferencedModelsToMainModel("TestNamespace", "DefaultContainer", modelTmp);
        }
コード例 #6
0
        public void WriterShouldNotIncludeTypeNameForCollectionOfDerivedType()
        {
            // JSON Light: writer doesn't include type name for collection of derived type
            // If I have a collection property declared in metadata as Collection(Edm.Geography), 
            // and at serialization type, it's clearly a Collection(Edm.GeographyPoint), 
            // we won't write the type name for that property by default (i.e., minimal metadata mode).

            var model = new EdmModel();
            var entityType = new EdmEntityType("Var1", "Type");
            entityType.AddKeys(entityType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
            entityType.AddProperty(new EdmStructuralProperty(entityType, "Geographies", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.Geography, false)))));
            model.AddElement(entityType);
            
            var writerSettings = new ODataMessageWriterSettings();
            writerSettings.SetContentType(ODataFormat.Json);
            writerSettings.DisableMessageStreamDisposal = true;

            var message = new InMemoryMessage { Stream = new MemoryStream() };
            using (ODataMessageWriter odataMessageWriter = new ODataMessageWriter((IODataRequestMessage)message, writerSettings, model))
            {
                ODataWriter odataWriter = odataMessageWriter.CreateODataEntryWriter();
                odataWriter.WriteStart(
                    new ODataEntry
                    {
                        TypeName = "Var1.Type",
                        Properties = new[] 
                        {
                            new ODataProperty() 
                            { 
                                Name = "Id", 
                                Value = 1 
                            }, 
                            new ODataProperty() 
                            { 
                                Name = "Geographies", 
                                Value = new ODataCollectionValue 
                                { 
                                    Items = new[] 
                                    { 
                                        GeographyPoint.Create(0,0),
                                        GeographyPoint.Create(1,1), 
                                        GeographyPoint.Create(2,2) 
                                    } 
                                } 
                            }, 
                        }
                    });
                odataWriter.WriteEnd();
                odataWriter.Flush();
            }
            
            message.Stream.Position = 0;
            var output = new StreamReader(message.Stream).ReadToEnd();
            Assert.IsFalse(output.Contains("Collection(Edm.GeographyPoint)"), @"output.Contains(""Collection(Edm.GeographyPoint)"" == false");
        }
コード例 #7
0
        private IEdmModel CreateTestModel()
        {
            EdmModel model = new EdmModel();
            EdmEntityContainer defaultContainer = new EdmEntityContainer("TestModel", "Default");
            model.AddElement(defaultContainer);

            var productType = new EdmEntityType("TestModel", "Product");
            EdmStructuralProperty idProperty = new EdmStructuralProperty(productType, "Id", EdmCoreModel.Instance.GetInt32(false));
            productType.AddProperty(idProperty);
            productType.AddKeys(idProperty);
            productType.AddProperty(new EdmStructuralProperty(productType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(productType);

            var customerType = new EdmEntityType("TestModel", "Customer");
            idProperty = new EdmStructuralProperty(customerType, "Id", EdmCoreModel.Instance.GetInt32(false));
            customerType.AddProperty(idProperty);
            customerType.AddKeys(idProperty);
            customerType.AddProperty(new EdmStructuralProperty(customerType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(productType);

            defaultContainer.AddEntitySet("Products", productType);
            defaultContainer.AddEntitySet("Customers", customerType);
            defaultContainer.AddSingleton("SingleProduct", productType);
            defaultContainer.AddSingleton("SingleCustomer", customerType);

            EdmAction action = new EdmAction("TestModel", "SimpleAction", null/*returnType*/, false /*isBound*/, null /*entitySetPath*/);
            model.AddElement(action);
            defaultContainer.AddActionImport("SimpleActionImport", action);

            EdmFunction function1 = new EdmFunction("TestModel", "SimpleFunction1", EdmCoreModel.Instance.GetInt32(false), false /*isbound*/, null, true);
            function1.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false));
            defaultContainer.AddFunctionImport("SimpleFunctionImport1", function1);

            EdmFunction function2 = new EdmFunction("TestModel", "SimpleFunction2", EdmCoreModel.Instance.GetInt32(false), false /*isbound*/, null, true);
            function2.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false));
            defaultContainer.AddFunctionImport("SimpleFunctionImport2", function1, null, true /*IncludeInServiceDocument*/);

            return model;
        }
コード例 #8
0
        /// <summary>
        /// Creates and adds a navigation property to this type and adds its navigation partner to the navigation target type.
        /// </summary>
        /// <param name="propertyInfo">Information to create the navigation property.</param>
        /// <param name="partnerInfo">Information to create the partner navigation property.</param>
        /// <returns>Created navigation property.</returns>
        public EdmNavigationProperty AddBidirectionalNavigation(EdmNavigationPropertyInfo propertyInfo, EdmNavigationPropertyInfo partnerInfo)
        {
            EdmUtil.CheckArgumentNull(propertyInfo, "propertyInfo");
            EdmUtil.CheckArgumentNull(propertyInfo.Target, "propertyInfo.Target");

            EdmEntityType targetType = propertyInfo.Target as EdmEntityType;

            if (targetType == null)
            {
                throw new ArgumentException("propertyInfo.Target", Strings.Constructable_TargetMustBeStock(typeof(EdmEntityType).FullName));
            }

            EdmNavigationProperty property = EdmNavigationProperty.CreateNavigationPropertyWithPartner(propertyInfo, this.FixUpDefaultPartnerInfo(propertyInfo, partnerInfo));

            this.AddProperty(property);
            targetType.AddProperty(property.Partner);
            return(property);
        }
コード例 #9
0
        static DeltaLinkWriterIntegrationTests()
        {
            Model = new EdmModel();
            EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
            Model.AddElement(EntityType);

            var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
            EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
            EntityType.AddProperty(keyProperty);
            var resourceNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
            var resourceSetNavigationProperty = EntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "ResourceSetNavigationProperty", Target = EntityType, TargetMultiplicity = EdmMultiplicity.Many });

            var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer");
            Model.AddElement(defaultContainer);
            EntitySet = new EdmEntitySet(defaultContainer, "TestEntitySet", EntityType);
            EntitySet.AddNavigationTarget(resourceNavigationProperty, EntitySet);
            EntitySet.AddNavigationTarget(resourceSetNavigationProperty, EntitySet);
            defaultContainer.AddElement(EntitySet);
        }
コード例 #10
0
        static ODataEntityReferenceLinksTests()
        {
            EdmModel tmpModel = new EdmModel();
            EdmComplexType complexType = new EdmComplexType("TestNamespace", "TestComplexType");
            complexType.AddProperty(new EdmStructuralProperty(complexType, "StringProperty", EdmCoreModel.Instance.GetString(false)));
            tmpModel.AddElement(complexType);

            EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
            tmpModel.AddElement(EntityType);
            var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
            EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
            EntityType.AddProperty(keyProperty);

            var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer_sub");
            tmpModel.AddElement(defaultContainer);
            EntitySet = new EdmEntitySet(defaultContainer, "Customers", EntityType);
            defaultContainer.AddElement(EntitySet);

            EdmModel = TestUtils.WrapReferencedModelsToMainModel("TestNamespace", "DefaultContainer", tmpModel);
            MessageReaderSettingsReadAndValidateCustomInstanceAnnotations = new ODataMessageReaderSettings { ShouldIncludeAnnotation = ODataUtils.CreateAnnotationFilter("*") };
       }
        static ODataJsonLightEntryAndFeedDeserializerTests()
        {
            EdmModel tmpModel = new EdmModel();
            EdmComplexType complexType = new EdmComplexType("TestNamespace", "TestComplexType");
            complexType.AddProperty(new EdmStructuralProperty(complexType, "StringProperty", EdmCoreModel.Instance.GetString(false)));
            tmpModel.AddElement(complexType);

            EntityType = new EdmEntityType("TestNamespace", "TestEntityType");
            tmpModel.AddElement(EntityType);
            var keyProperty = new EdmStructuralProperty(EntityType, "ID", EdmCoreModel.Instance.GetInt32(false));
            EntityType.AddKeys(new IEdmStructuralProperty[] { keyProperty });
            EntityType.AddProperty(keyProperty);

            var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer_sub");
            tmpModel.AddElement(defaultContainer);
            EntitySet = new EdmEntitySet(defaultContainer, "TestEntitySet", EntityType);
            defaultContainer.AddElement(EntitySet);

            Action = new EdmAction("TestNamespace", "DoSomething", null, true, null);
            Action.AddParameter("p1", new EdmEntityTypeReference(EntityType, false));
            tmpModel.AddElement(Action);

            ActionImport = defaultContainer.AddActionImport("DoSomething", Action);

            var serviceOperationFunction = new EdmFunction("TestNamespace", "ServiceOperation", EdmCoreModel.Instance.GetInt32(true));
            defaultContainer.AddFunctionImport("ServiceOperation", serviceOperationFunction);
            tmpModel.AddElement(serviceOperationFunction);

            tmpModel.AddElement(new EdmTerm("custom", "DateTimeOffsetAnnotation", EdmPrimitiveTypeKind.DateTimeOffset));
            tmpModel.AddElement(new EdmTerm("custom", "DateAnnotation", EdmPrimitiveTypeKind.Date));
            tmpModel.AddElement(new EdmTerm("custom", "TimeOfDayAnnotation", EdmPrimitiveTypeKind.TimeOfDay));

            EdmModel = TestUtils.WrapReferencedModelsToMainModel("TestNamespace", "DefaultContainer", tmpModel);
            MessageReaderSettingsReadAndValidateCustomInstanceAnnotations = new ODataMessageReaderSettings { ShouldIncludeAnnotation = ODataUtils.CreateAnnotationFilter("*") };
            MessageReaderSettingsIgnoreInstanceAnnotations = new ODataMessageReaderSettings();
        }
コード例 #12
0
        public void TestElementInterfaceCriticalPropertyValueMustNotBeNull()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalPropertyValueMustNotBeNull }
            };

            var baseEntity = new EdmEntityType("DefaultNamespace", "BaseEntity");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = baseEntity,
                Partner = new StubEdmNavigationProperty("Partner") { DeclaringType = baseEntity, Type = new EdmEntityTypeReference(baseEntity, false) }
            };
            baseEntity.AddProperty(navProperty);

            this.ValidateElement(navProperty, expectedErrors);
            this.ValidateElement(baseEntity, expectedErrors);

            expectedErrors = new EdmLibTestErrors();
            var entity = new EdmEntityType("DefaultNamespace", "Entity", baseEntity);
            this.ValidateElement(entity, expectedErrors);
        }
コード例 #13
0
        public static IEdmModel CreateModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "DefaultContainer");
            model.AddElement(defaultContainer);

            var nameType = new EdmTypeDefinition(ns, "Name", EdmPrimitiveTypeKind.String);
            model.AddElement(nameType);

            var addressType = new EdmComplexType(ns, "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Road", new EdmTypeDefinitionReference(nameType, false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(addressType);

            var personType = new EdmEntityType(ns, "Person");
            var personIdProperty = new EdmStructuralProperty(personType, "PersonId", EdmCoreModel.Instance.GetInt32(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
            personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", new EdmTypeDefinitionReference(nameType, false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "LastName", new EdmTypeDefinitionReference(nameType, false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Address", new EdmComplexTypeReference(addressType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Descriptions", new EdmCollectionTypeReference(new EdmCollectionType(new EdmTypeDefinitionReference(nameType, false)))));

            model.AddElement(personType);
            var peopleSet = new EdmEntitySet(defaultContainer, "People", personType);
            defaultContainer.AddElement(peopleSet);

            var numberComboType = new EdmComplexType(ns, "NumberCombo");
            numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Small", model.GetUInt16(ns, false)));
            numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Middle", model.GetUInt32(ns, false)));
            numberComboType.AddProperty(new EdmStructuralProperty(numberComboType, "Large", model.GetUInt64(ns, false)));
            model.AddElement(numberComboType);

            var productType = new EdmEntityType(ns, "Product");
            var productIdProperty = new EdmStructuralProperty(productType, "ProductId", model.GetUInt16(ns, false));
            productType.AddProperty(productIdProperty);
            productType.AddKeys(new IEdmStructuralProperty[] { productIdProperty });
            productType.AddProperty(new EdmStructuralProperty(productType, "Quantity", model.GetUInt32(ns, false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "NullableUInt32", model.GetUInt32(ns, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "LifeTimeInSeconds", model.GetUInt64(ns, false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "TheCombo", new EdmComplexTypeReference(numberComboType, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "LargeNumbers", new EdmCollectionTypeReference(new EdmCollectionType(model.GetUInt64(ns, false)))));

            model.AddElement(productType);
            var productsSet = new EdmEntitySet(defaultContainer, "Products", productType);
            defaultContainer.AddElement(productsSet);

            //Bound Function: bound to entity, return defined type
            var getFullNameFunction = new EdmFunction(ns, "GetFullName", new EdmTypeDefinitionReference(nameType, false), true, null, false);
            getFullNameFunction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            getFullNameFunction.AddParameter("nickname", new EdmTypeDefinitionReference(nameType, false));
            model.AddElement(getFullNameFunction);

            //Bound Action: bound to entity, return UInt64
            var extendLifeTimeAction = new EdmAction(ns, "ExtendLifeTime", model.GetUInt64(ns, false), true, null);
            extendLifeTimeAction.AddParameter("product", new EdmEntityTypeReference(productType, false));
            extendLifeTimeAction.AddParameter("seconds", model.GetUInt32(ns, false));
            model.AddElement(extendLifeTimeAction);

            //UnBound Action: ResetDataSource
            var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
            model.AddElement(resetDataSourceAction);
            defaultContainer.AddActionImport(resetDataSourceAction);

            IEnumerable<EdmError> errors = null;
            model.Validate(out errors);

            return model;
        }
コード例 #14
0
        public static IEdmModel CreateModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "DefaultContainer");
            model.AddElement(defaultContainer);

            var orderDetail = new EdmComplexType(ns, "orderDetail");
            orderDetail.AddProperty(new EdmStructuralProperty(orderDetail, "amount", EdmCoreModel.Instance.GetDecimal(false)));
            orderDetail.AddProperty(new EdmStructuralProperty(orderDetail, "quantity", EdmCoreModel.Instance.GetInt32(false)));
            model.AddElement(orderDetail);

            var billingType = new EdmEnumType(ns, "billingType", EdmPrimitiveTypeKind.Int64, false);
            billingType.AddMember("fund", new EdmIntegerConstant(0));
            billingType.AddMember("refund", new EdmIntegerConstant(1));
            billingType.AddMember("chargeback", new EdmIntegerConstant(2));
            model.AddElement(billingType);

            var category = new EdmEnumType(ns, "category", true);
            category.AddMember("toy", new EdmIntegerConstant(1));
            category.AddMember("food", new EdmIntegerConstant(2));
            category.AddMember("cloth", new EdmIntegerConstant(4));
            category.AddMember("drink", new EdmIntegerConstant(8));
            category.AddMember("computer", new EdmIntegerConstant(16));
            model.AddElement(category);

            var namedObject = new EdmEntityType(ns, "namedObject");
            var idProperty = new EdmStructuralProperty(namedObject, "id", EdmCoreModel.Instance.GetInt32(false));
            namedObject.AddProperty(idProperty);
            namedObject.AddKeys(idProperty);
            namedObject.AddProperty(new EdmStructuralProperty(namedObject, "name", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(namedObject);

            var order = new EdmEntityType(ns, "order", namedObject);
            order.AddProperty(new EdmStructuralProperty(order, "description", EdmCoreModel.Instance.GetString(false)));
            order.AddProperty(new EdmStructuralProperty(order, "detail", new EdmComplexTypeReference(orderDetail, true)));
            order.AddProperty(new EdmStructuralProperty(order, "lineItems",
                new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            order.AddProperty(new EdmStructuralProperty(order, "categories", new EdmEnumTypeReference(category, false)));
            model.AddElement(order);

            var billingRecord = new EdmEntityType(ns, "billingRecord", namedObject);
            billingRecord.AddProperty(new EdmStructuralProperty(billingRecord, "amount", EdmCoreModel.Instance.GetDecimal(false)));
            billingRecord.AddProperty(new EdmStructuralProperty(billingRecord, "type", new EdmEnumTypeReference(billingType, false)));
            model.AddElement(billingRecord);

            var store = new EdmEntityType(ns, "store", namedObject);
            store.AddProperty(new EdmStructuralProperty(store, "address", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(store);

            var orders = new EdmEntitySet(defaultContainer, "orders", order);
            defaultContainer.AddElement(orders);

            var billingRecords = new EdmEntitySet(defaultContainer, "billingRecords", billingRecord);
            defaultContainer.AddElement(billingRecords);

            var myStore = new EdmSingleton(defaultContainer, "myStore", store);
            defaultContainer.AddElement(myStore);

            var order2billingRecord = order.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "billingRecords",
                Target = billingRecord,
                TargetMultiplicity = EdmMultiplicity.Many
            });

            ((EdmEntitySet)orders).AddNavigationTarget(order2billingRecord, billingRecords);

            IEnumerable<EdmError> errors = null;
            model.Validate(out errors);

            return model;
        }
コード例 #15
0
        public void WriteContainedFeed()
        {
            EdmEntityType entityType = new EdmEntityType("NS", "Entity");
            entityType.AddProperty(new EdmStructuralProperty(entityType, "Id", EdmCoreModel.Instance.GetInt32(false)));

            EdmEntityType expandEntityType = new EdmEntityType("NS", "ExpandEntity");
            expandEntityType.AddProperty(new EdmStructuralProperty(expandEntityType, "Id", EdmCoreModel.Instance.GetInt32(false)));
            expandEntityType.AddProperty(new EdmStructuralProperty(expandEntityType, "Name", EdmCoreModel.Instance.GetString(false)));

            entityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { ContainsTarget = true, Name = "Property1", Target = expandEntityType, TargetMultiplicity = EdmMultiplicity.Many });

            EdmOperation operation = new EdmFunction("NS", "Foo", EdmCoreModel.Instance.GetInt16(true));
            operation.AddParameter("entry", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(entityType, false))));

            Action<ODataJsonLightOutputContext> test = outputContext =>
            {
                var entry1 = new ODataEntry();
                entry1.Properties = new List<ODataProperty>()
                {
                    new ODataProperty() { Name = "ID", Value = 1 }, 
                };

                var entry2 = new ODataEntry();
                entry2.Properties = new List<ODataProperty>()
                {
                    new ODataProperty() { Name = "ID", Value = 1 }, 
                    new ODataProperty() { Name = "Name", Value = "TestName"}
                };

                var parameterWriter = new ODataJsonLightParameterWriter(outputContext, operation: null);
                parameterWriter.WriteStart();
                var entryWriter = parameterWriter.CreateFeedWriter("feed");
                entryWriter.WriteStart(new ODataFeed());
                entryWriter.WriteStart(entry1);
                entryWriter.WriteStart(new ODataNavigationLink()
                {
                    Name = "Property1",
                    IsCollection = true
                });
                entryWriter.WriteStart(new ODataFeed());
                entryWriter.WriteStart(entry2);
                entryWriter.WriteEnd();
                entryWriter.WriteEnd();
                entryWriter.WriteEnd();
                entryWriter.WriteEnd();
                entryWriter.WriteEnd();
                parameterWriter.WriteEnd();
                parameterWriter.Flush();
            };

            WriteAndValidate(test, "{\"feed\":[{\"ID\":1,\"Property1\":[{\"ID\":1,\"Name\":\"TestName\"}]}]}", writingResponse: false);
        }
コード例 #16
0
        public void WriteDerivedEntityInFeed()
        {
            EdmEntityType entityType = new EdmEntityType("NS", "Entity");
            IEdmStructuralProperty keyProp = new EdmStructuralProperty(entityType, "Id", EdmCoreModel.Instance.GetInt32(false));
            entityType.AddProperty(keyProp);
            entityType.AddKeys(keyProp);

            EdmEntityType derivedType = new EdmEntityType("NS", "DerivedType", entityType);
            derivedType.AddProperty(new EdmStructuralProperty(derivedType, "Name", EdmCoreModel.Instance.GetString(false)));

            EdmOperation operation = new EdmFunction("NS", "Foo", EdmCoreModel.Instance.GetInt16(true));
            operation.AddParameter("feed", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(entityType, false))));

            Action<ODataJsonLightOutputContext> test = outputContext =>
            {
                var entry = new ODataEntry()
                {
                    TypeName = "NS.DerivedType",
                };
                entry.Properties = new List<ODataProperty>()
                {
                    new ODataProperty() { Name = "ID", Value = 1 }, 
                    new ODataProperty() { Name = "Name", Value = "TestName"}
                };

                var parameterWriter = new ODataJsonLightParameterWriter(outputContext, operation: null);
                parameterWriter.WriteStart();
                var entryWriter = parameterWriter.CreateFeedWriter("feed");
                entryWriter.WriteStart(new ODataFeed());
                entryWriter.WriteStart(entry);
                entryWriter.WriteEnd();
                entryWriter.WriteEnd();
                parameterWriter.WriteEnd();
                parameterWriter.Flush();
            };

            WriteAndValidate(test, "{\"feed\":[{\"@odata.type\":\"#NS.DerivedType\",\"ID\":1,\"Name\":\"TestName\"}]}", writingResponse: false);
        }
コード例 #17
0
        public void WriteNullEntryWithOperation()
        {
            EdmEntityType entityType = new EdmEntityType("NS", "Entity");
            IEdmStructuralProperty keyProp = new EdmStructuralProperty(entityType, "Id", EdmCoreModel.Instance.GetInt32(false));
            entityType.AddProperty(keyProp);
            entityType.AddKeys(keyProp);

            EdmOperation operation = new EdmFunction("NS", "Foo", EdmCoreModel.Instance.GetInt16(true));
            operation.AddParameter("entry", new EdmEntityTypeReference(entityType, true));

            Action<ODataJsonLightOutputContext> test = outputContext =>
            {
                var parameterWriter = new ODataJsonLightParameterWriter(outputContext, operation);
                parameterWriter.WriteStart();

                var entryWriter = parameterWriter.CreateEntryWriter("entry");
                entryWriter.WriteStart((ODataEntry)null);
                entryWriter.WriteEnd();

                parameterWriter.WriteEnd();
                parameterWriter.Flush();
            };

            WriteAndValidate(test, "{\"entry\":null}", writingResponse: false);
        }
コード例 #18
0
        public static IEdmModel CreateTripPinServiceModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "DefaultContainer");
            model.AddElement(defaultContainer);

            var genderType = new EdmEnumType(ns, "PersonGender", isFlags: false);
            genderType.AddMember("Male", new EdmIntegerConstant(0));
            genderType.AddMember("Female", new EdmIntegerConstant(1));
            genderType.AddMember("Unknown", new EdmIntegerConstant(2));
            model.AddElement(genderType);

            var cityType = new EdmComplexType(ns, "City");
            cityType.AddProperty(new EdmStructuralProperty(cityType, "CountryRegion", EdmCoreModel.Instance.GetString(false)));
            cityType.AddProperty(new EdmStructuralProperty(cityType, "Name", EdmCoreModel.Instance.GetString(false)));
            cityType.AddProperty(new EdmStructuralProperty(cityType, "Region", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(cityType);

            var locationType = new EdmComplexType(ns, "Location", null, false, true);
            locationType.AddProperty(new EdmStructuralProperty(locationType, "Address", EdmCoreModel.Instance.GetString(false)));
            locationType.AddProperty(new EdmStructuralProperty(locationType, "City", new EdmComplexTypeReference(cityType, false)));
            model.AddElement(locationType);

            var eventLocationType = new EdmComplexType(ns, "EventLocation", locationType, false, true);
            eventLocationType.AddProperty(new EdmStructuralProperty(eventLocationType, "BuildingInfo", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(eventLocationType);

            var airportLocationType = new EdmComplexType(ns, "AirportLocation", locationType, false, true);
            airportLocationType.AddProperty(new EdmStructuralProperty(airportLocationType, "Loc", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, false)));
            model.AddElement(airportLocationType);

            var photoType = new EdmEntityType(ns, "Photo", null, false, false, true);
            var photoIdProperty = new EdmStructuralProperty(photoType, "Id", EdmCoreModel.Instance.GetInt64(false));
            photoType.AddProperty(photoIdProperty);
            photoType.AddKeys(photoIdProperty);
            photoType.AddProperty(new EdmStructuralProperty(photoType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(photoType);

            var photoSet = new EdmEntitySet(defaultContainer, "Photos", photoType);
            defaultContainer.AddElement(photoSet);

            var personType = new EdmEntityType(ns, "Person", null, false, /* isOpen */ true);
            var personIdProperty = new EdmStructuralProperty(personType, "UserName", EdmCoreModel.Instance.GetString(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(personIdProperty);
            personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Emails", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true)))));
            personType.AddProperty(new EdmStructuralProperty(personType, "AddressInfo", new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(locationType, true)))));
            personType.AddProperty(new EdmStructuralProperty(personType, "Gender", new EdmEnumTypeReference(genderType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Concurrency", EdmCoreModel.Instance.GetInt64(false)));
            model.AddElement(personType);

            var personSet = new EdmEntitySet(defaultContainer, "People", personType);
            defaultContainer.AddElement(personSet);

            var airlineType = new EdmEntityType(ns, "Airline");
            var airlineCodeProp = new EdmStructuralProperty(airlineType, "AirlineCode", EdmCoreModel.Instance.GetString(false));
            airlineType.AddKeys(airlineCodeProp);
            airlineType.AddProperty(airlineCodeProp);
            airlineType.AddProperty(new EdmStructuralProperty(airlineType, "Name", EdmCoreModel.Instance.GetString(false)));

            model.AddElement(airlineType);
            var airlineSet = new EdmEntitySet(defaultContainer, "Airlines", airlineType);
            defaultContainer.AddElement(airlineSet);

            var airportType = new EdmEntityType(ns, "Airport");
            var airportIdType = new EdmStructuralProperty(airportType, "IcaoCode", EdmCoreModel.Instance.GetString(false));
            airportType.AddProperty(airportIdType);
            airportType.AddKeys(airportIdType);
            airportType.AddProperty(new EdmStructuralProperty(airportType, "Name", EdmCoreModel.Instance.GetString(false)));
            airportType.AddProperty(new EdmStructuralProperty(airportType, "IataCode", EdmCoreModel.Instance.GetString(false)));
            airportType.AddProperty(new EdmStructuralProperty(airportType, "Location", new EdmComplexTypeReference(airportLocationType, false)));
            model.AddElement(airportType);

            var airportSet = new EdmEntitySet(defaultContainer, "Airports", airportType);
            defaultContainer.AddElement(airportSet);

            var planItemType = new EdmEntityType(ns, "PlanItem");
            var planItemIdType = new EdmStructuralProperty(planItemType, "PlanItemId", EdmCoreModel.Instance.GetInt32(false));
            planItemType.AddProperty(planItemIdType);
            planItemType.AddKeys(planItemIdType);
            planItemType.AddProperty(new EdmStructuralProperty(planItemType, "ConfirmationCode", EdmCoreModel.Instance.GetString(true)));
            planItemType.AddProperty(new EdmStructuralProperty(planItemType, "StartsAt", EdmCoreModel.Instance.GetDateTimeOffset(true)));
            planItemType.AddProperty(new EdmStructuralProperty(planItemType, "EndsAt", EdmCoreModel.Instance.GetDateTimeOffset(true)));
            planItemType.AddProperty(new EdmStructuralProperty(planItemType, "Duration", EdmCoreModel.Instance.GetDuration(true)));
            model.AddElement(planItemType);

            var publicTransportationType = new EdmEntityType(ns, "PublicTransportation", planItemType);
            publicTransportationType.AddProperty(new EdmStructuralProperty(publicTransportationType, "SeatNumber", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(publicTransportationType);

            var flightType = new EdmEntityType(ns, "Flight", publicTransportationType);
            var flightNumberType = new EdmStructuralProperty(flightType, "FlightNumber", EdmCoreModel.Instance.GetString(false));
            flightType.AddProperty(flightNumberType);
            model.AddElement(flightType);

            var eventType = new EdmEntityType(ns, "Event", planItemType, false, true);
            eventType.AddProperty(new EdmStructuralProperty(eventType, "Description", EdmCoreModel.Instance.GetString(true)));
            eventType.AddProperty(new EdmStructuralProperty(eventType, "OccursAt", new EdmComplexTypeReference(eventLocationType, false)));
            model.AddElement(eventType);

            var tripType = new EdmEntityType(ns, "Trip");
            var tripIdType = new EdmStructuralProperty(tripType, "TripId", EdmCoreModel.Instance.GetInt32(false));
            tripType.AddProperty(tripIdType);
            tripType.AddKeys(tripIdType);
            tripType.AddProperty(new EdmStructuralProperty(tripType, "ShareId", EdmCoreModel.Instance.GetGuid(true)));
            tripType.AddProperty(new EdmStructuralProperty(tripType, "Description", EdmCoreModel.Instance.GetString(true)));
            tripType.AddProperty(new EdmStructuralProperty(tripType, "Name", EdmCoreModel.Instance.GetString(false)));
            tripType.AddProperty(new EdmStructuralProperty(tripType, "Budget", EdmCoreModel.Instance.GetSingle(false)));
            tripType.AddProperty(new EdmStructuralProperty(tripType, "StartsAt", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            tripType.AddProperty(new EdmStructuralProperty(tripType, "EndsAt", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            tripType.AddProperty(new EdmStructuralProperty(tripType, "Tags", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            model.AddElement(tripType);

            var friendsnNavigation = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Friends",
                Target = personType,
                TargetMultiplicity = EdmMultiplicity.Many
            });

            var personTripNavigation = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Trips",
                Target = tripType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var personPhotoNavigation = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Photo",
                Target = photoType,
                TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
            });

            var tripPhotosNavigation = tripType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Photos",
                Target = photoType,
                TargetMultiplicity = EdmMultiplicity.Many,
            });

            var tripItemNavigation = tripType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "PlanItems",
                Target = planItemType,
                ContainsTarget = true,
                TargetMultiplicity = EdmMultiplicity.Many
            });

            var flightFromAirportNavigation = flightType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "From",
                Target = airportType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var flightToAirportNavigation = flightType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "To",
                Target = airportType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var flightAirlineNavigation = flightType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Airline",
                Target = airlineType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var me = new EdmSingleton(defaultContainer, "Me", personType);
            defaultContainer.AddElement(me);

            personSet.AddNavigationTarget(friendsnNavigation, personSet);
            me.AddNavigationTarget(friendsnNavigation, personSet);

            personSet.AddNavigationTarget(flightAirlineNavigation, airlineSet);
            me.AddNavigationTarget(flightAirlineNavigation, airlineSet);

            personSet.AddNavigationTarget(flightFromAirportNavigation, airportSet);
            me.AddNavigationTarget(flightFromAirportNavigation, airportSet);

            personSet.AddNavigationTarget(flightToAirportNavigation, airportSet);
            me.AddNavigationTarget(flightToAirportNavigation, airportSet);

            personSet.AddNavigationTarget(personPhotoNavigation, photoSet);
            me.AddNavigationTarget(personPhotoNavigation, photoSet);

            personSet.AddNavigationTarget(tripPhotosNavigation, photoSet);
            me.AddNavigationTarget(tripPhotosNavigation, photoSet);

            var getFavoriteAirlineFunction = new EdmFunction(ns, "GetFavoriteAirline",
                new EdmEntityTypeReference(airlineType, false), true,
                new EdmPathExpression("person/Trips/PlanItems/Microsoft.OData.SampleService.Models.TripPin.Flight/Airline"), true);
            getFavoriteAirlineFunction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            model.AddElement(getFavoriteAirlineFunction);

            var getInvolvedPeopleFunction = new EdmFunction(ns, "GetInvolvedPeople",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(personType, false))), true, null, true);
            getInvolvedPeopleFunction.AddParameter("trip", new EdmEntityTypeReference(tripType, false));
            model.AddElement(getInvolvedPeopleFunction);

            var getFriendsTripsFunction = new EdmFunction(ns, "GetFriendsTrips",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(tripType, false))),
                true, new EdmPathExpression("person/Friends/Trips"), true);
            getFriendsTripsFunction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            getFriendsTripsFunction.AddParameter("userName", EdmCoreModel.Instance.GetString(false));
            model.AddElement(getFriendsTripsFunction);

            var getNearestAirport = new EdmFunction(ns, "GetNearestAirport",
                new EdmEntityTypeReference(airportType, false),
                false, null, true);
            getNearestAirport.AddParameter("lat", EdmCoreModel.Instance.GetDouble(false));
            getNearestAirport.AddParameter("lon", EdmCoreModel.Instance.GetDouble(false));
            model.AddElement(getNearestAirport);
            var getNearestAirportFunctionImport = (IEdmFunctionImport)defaultContainer.AddFunctionImport("GetNearestAirport", getNearestAirport, new EdmEntitySetReferenceExpression(airportSet), true);

            var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
            model.AddElement(resetDataSourceAction);
            defaultContainer.AddActionImport(resetDataSourceAction);

            var shareTripAction = new EdmAction(ns, "ShareTrip", null, true, null);
            shareTripAction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            shareTripAction.AddParameter("userName", EdmCoreModel.Instance.GetString(false));
            shareTripAction.AddParameter("tripId", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(shareTripAction);

            model.SetDescriptionAnnotation(defaultContainer, "TripPin service is a sample service for OData V4.");
            model.SetOptimisticConcurrencyAnnotation(personSet, personType.StructuralProperties().Where(p => p.Name == "Concurrency"));
            // TODO: currently singleton does not support ETag feature
            // model.SetOptimisticConcurrencyAnnotation(me, personType.StructuralProperties().Where(p => p.Name == "Concurrency"));
            model.SetResourcePathCoreAnnotation(personSet, "People");
            model.SetResourcePathCoreAnnotation(me, "Me");
            model.SetResourcePathCoreAnnotation(airlineSet, "Airlines");
            model.SetResourcePathCoreAnnotation(airportSet, "Airports");
            model.SetResourcePathCoreAnnotation(photoSet, "Photos");
            model.SetResourcePathCoreAnnotation(getNearestAirportFunctionImport, "Microsoft.OData.SampleService.Models.TripPin.GetNearestAirport");
            model.SetDereferenceableIDsCoreAnnotation(defaultContainer, true);
            model.SetConventionalIDsCoreAnnotation(defaultContainer, true);
            model.SetPermissionsCoreAnnotation(personType.FindProperty("UserName"), CorePermission.Read);
            model.SetPermissionsCoreAnnotation(airlineType.FindProperty("AirlineCode"), CorePermission.Read);
            model.SetPermissionsCoreAnnotation(airportType.FindProperty("IcaoCode"), CorePermission.Read);
            model.SetPermissionsCoreAnnotation(planItemType.FindProperty("PlanItemId"), CorePermission.Read);
            model.SetPermissionsCoreAnnotation(tripType.FindProperty("TripId"), CorePermission.Read);
            model.SetPermissionsCoreAnnotation(photoType.FindProperty("Id"), CorePermission.Read);
            model.SetImmutableCoreAnnotation(airportType.FindProperty("IataCode"), true);
            model.SetComputedCoreAnnotation(personType.FindProperty("Concurrency"), true);
            model.SetAcceptableMediaTypesCoreAnnotation(photoType, new[] { "image/jpeg" });
            model.SetConformanceLevelCapabilitiesAnnotation(defaultContainer, CapabilitiesConformanceLevelType.Advanced);
            model.SetSupportedFormatsCapabilitiesAnnotation(defaultContainer, new[] { "application/json;odata.metadata=full;IEEE754Compatible=false;odata.streaming=true", "application/json;odata.metadata=minimal;IEEE754Compatible=false;odata.streaming=true", "application/json;odata.metadata=none;IEEE754Compatible=false;odata.streaming=true" });
            model.SetAsynchronousRequestsSupportedCapabilitiesAnnotation(defaultContainer, true);
            model.SetBatchContinueOnErrorSupportedCapabilitiesAnnotation(defaultContainer, false);
            model.SetNavigationRestrictionsCapabilitiesAnnotation(personSet, CapabilitiesNavigationType.None, new[] { new Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>(friendsnNavigation, CapabilitiesNavigationType.Recursive) });
            model.SetFilterFunctionsCapabilitiesAnnotation(defaultContainer, new[] { "contains", "endswith", "startswith", "length", "indexof", "substring", "tolower", "toupper", "trim", "concat", "year", "month", "day", "hour", "minute", "second", "round", "floor", "ceiling", "cast", "isof" });
            model.SetSearchRestrictionsCapabilitiesAnnotation(personSet, true, CapabilitiesSearchExpressions.None);
            model.SetSearchRestrictionsCapabilitiesAnnotation(airlineSet, true, CapabilitiesSearchExpressions.None);
            model.SetSearchRestrictionsCapabilitiesAnnotation(airportSet, true, CapabilitiesSearchExpressions.None);
            model.SetSearchRestrictionsCapabilitiesAnnotation(photoSet, true, CapabilitiesSearchExpressions.None);
            model.SetInsertRestrictionsCapabilitiesAnnotation(personSet, true, new[] { personTripNavigation, friendsnNavigation });
            model.SetInsertRestrictionsCapabilitiesAnnotation(airlineSet, true, null);
            model.SetInsertRestrictionsCapabilitiesAnnotation(airportSet, false, null);
            model.SetInsertRestrictionsCapabilitiesAnnotation(photoSet, true, null);
            // TODO: model.SetUpdateRestrictionsCapabilitiesAnnotation();
            model.SetDeleteRestrictionsCapabilitiesAnnotation(airportSet, false, null);
            model.SetISOCurrencyMeasuresAnnotation(tripType.FindProperty("Budget"), "USD");
            model.SetScaleMeasuresAnnotation(tripType.FindProperty("Budget"), 2);

            return model;
        }
コード例 #19
0
        public void TestManytoManyRelationshipWithOneNavigiationPropertyInOneOfThem()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalNavigationPartnerInvalid }
            };

            var entity1 = new EdmEntityType("DefaultNamespace", "Entity1");
            var entity2 = new EdmEntityType("DefaultNamespace", "Entity2");

            var navProperty1 = new StubEdmNavigationProperty("Nav1")
            {
                DeclaringType = entity1,
                Type = new EdmEntityTypeReference(entity2, false),
            };

            var navProperty2 = new StubEdmNavigationProperty("Nav2")
            {
                DeclaringType = entity1,
                Type = new EdmEntityTypeReference(entity2, false),
            };

            var navProperty3 = new StubEdmNavigationProperty("Nav3")
            {
                DeclaringType = entity2,
                Type = new EdmEntityTypeReference(entity1, false),
            };

            navProperty1.Partner = navProperty3;
            navProperty2.Partner = navProperty3;
            navProperty3.Partner = navProperty1;

            entity1.AddProperty(navProperty1);
            entity1.AddProperty(navProperty2);
            entity2.AddProperty(navProperty3);

            var model = new EdmModel();
            model.AddElement(entity1);
            model.AddElement(entity2);

            this.ValidateUsingEdmValidator(model, expectedErrors);
        }
コード例 #20
0
 private EdmModel CreateEdmModelWithEntity()
 {
     var model = new EdmModel();
     var entityType = new EdmEntityType("TestNamespace", "Customer");
     entityType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
     EdmStructuralProperty id = new EdmStructuralProperty(entityType, "FloatId", EdmCoreModel.Instance.GetSingle(false));
     entityType.AddKeys(id);
     entityType.AddProperty(id);
     model.AddElement(entityType);
     var defaultContainer = new EdmEntityContainer("TestNamespace", "DefaultContainer_sub");
     var entitySet = new EdmEntitySet(defaultContainer, "Customers", entityType);
     defaultContainer.AddEntitySet(entitySet.Name, entityType);
     model.AddElement(defaultContainer);
     return model;
 }
コード例 #21
0
        public static IEdmModel AllInterfaceCriticalModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(valueTerm);

            var badString = new CustomStringConstant("foo", EdmExpressionKind.None, EdmValueKind.Integer);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                badString);
            model.AddVocabularyAnnotation(valueAnnotation);

            var mutableValueAnnotationueAnnotation = new MutableValueAnnotation()
            {
                Target = valueTerm
            };

            model.AddVocabularyAnnotation(mutableValueAnnotationueAnnotation);
            
            var customEntity = new CustomEntityType(new List<IEdmProperty>() { null });
            model.AddElement(customEntity);

            var entity = new EdmEntityType("DefaultNamespace", "bar");
            var entity2 = new EdmEntityType("DefaultNamespace", "bar2");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = entity,
                Type = new EdmEntityTypeReference(entity2, false)
            };

            navProperty.Partner = navProperty;
            entity.AddProperty(navProperty);
            model.AddElement(entity);
            model.AddElement(entity2);

            return model;
        }
コード例 #22
0
        public void TestInitialize()
        {
            this.testServiceRootUri = new Uri(TestBaseUri);

            this.model = new EdmModel();

            var defaultContainer = new EdmEntityContainer(TestNameSpace, TestContainerName);
            this.model.AddElement(defaultContainer);

            productType = new EdmEntityType(TestNameSpace, "Product");
            var productIdProperty = new EdmStructuralProperty(productType, "PersonId", EdmCoreModel.Instance.GetInt32(false));
            productType.AddProperty(productIdProperty);
            productType.AddKeys(new IEdmStructuralProperty[] { productIdProperty });
            productType.AddProperty(new EdmStructuralProperty(productType, "Name", EdmCoreModel.Instance.GetString(false)));
            this.model.AddElement(productType);

            productBookType = new EdmEntityType(TestNameSpace, "ProductBook", productType);
            productBookType.AddProperty(new EdmStructuralProperty(productBookType, "Author", EdmCoreModel.Instance.GetString(false)));
            this.model.AddElement(productBookType);

            productCdType = new EdmEntityType(TestNameSpace, "ProductCd", productType);
            productCdType.AddProperty(new EdmStructuralProperty(productCdType, "Artist", EdmCoreModel.Instance.GetString(false)));
            this.model.AddElement(productCdType);

            var addressType = new EdmComplexType(TestNameSpace, "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
            this.model.AddElement(addressType);

            var factoryAddressType = new EdmComplexType(TestNameSpace, "FactoryAddress", addressType, false);
            factoryAddressType.AddProperty(new EdmStructuralProperty(factoryAddressType, "FactoryType", EdmCoreModel.Instance.GetString(false)));
            factoryAddressType.AddProperty(new EdmStructuralProperty(factoryAddressType, "FactoryPhoneNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            this.model.AddElement(factoryAddressType);

            var manufactoryType = new EdmComplexType(TestNameSpace, "Manufactory");
            manufactoryType.AddProperty(new EdmStructuralProperty(manufactoryType, "ManufactoryAddress", new EdmComplexTypeReference(addressType, true)));
            manufactoryType.AddProperty(new EdmStructuralProperty(manufactoryType, "Name", EdmCoreModel.Instance.GetString(false)));
            manufactoryType.AddProperty(new EdmStructuralProperty(manufactoryType, "Numbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            this.model.AddElement(manufactoryType);

            var companyDivisionType = new EdmComplexType(TestNameSpace, "Division");
            companyDivisionType.AddProperty(new EdmStructuralProperty(companyDivisionType, "Name", EdmCoreModel.Instance.GetString(false)));
            companyDivisionType.AddProperty(new EdmStructuralProperty(companyDivisionType, "Manufactory", new EdmComplexTypeReference(manufactoryType, true)));
            this.model.AddElement(companyDivisionType);

            var accessLevelType = new EdmEnumType(TestNameSpace, "AccessLevel", isFlags: true);
            accessLevelType.AddMember("None", new EdmIntegerConstant(0));
            accessLevelType.AddMember("Read", new EdmIntegerConstant(1));
            accessLevelType.AddMember("Write", new EdmIntegerConstant(2));
            accessLevelType.AddMember("Execute", new EdmIntegerConstant(4));
            accessLevelType.AddMember("ReadWrite", new EdmIntegerConstant(3));
            this.model.AddElement(accessLevelType);

            personType = new EdmEntityType(TestNameSpace, "Person", null, false, /*IsOpen*/ true);
            var personIdProperty = new EdmStructuralProperty(personType, "PersonId", EdmCoreModel.Instance.GetInt32(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
            personType.AddProperty(new EdmStructuralProperty(personType, "Name", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Age", EdmCoreModel.Instance.GetInt32(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "HomeAddress", new EdmComplexTypeReference(addressType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "PhoneNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            personType.AddProperty(new EdmStructuralProperty(personType, "Addresses", new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(addressType, true)))));
            personType.AddProperty(new EdmStructuralProperty(personType, "UserAccess", new EdmEnumTypeReference(accessLevelType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "UserAccesses", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEnumTypeReference(accessLevelType, true)))));

            this.model.AddElement(personType);

            employeeType = new EdmEntityType(TestNameSpace, "Employee", personType, false, true);
            employeeType.AddProperty(new EdmStructuralProperty(employeeType, "DateHired", EdmCoreModel.Instance.GetDateTimeOffset(true)));
            employeeType.AddProperty(new EdmStructuralProperty(employeeType, "WorkNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            this.model.AddElement(employeeType);

            companyType = new EdmEntityType(TestNameSpace, "Company");
            var companyIdProperty = new EdmStructuralProperty(companyType, "CompanyId", EdmCoreModel.Instance.GetInt32(false));
            companyType.AddProperty(companyIdProperty);
            companyType.AddKeys(new IEdmStructuralProperty[] { companyIdProperty });
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Name", EdmCoreModel.Instance.GetString(false)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Division", new EdmComplexTypeReference(companyDivisionType, true)));
            this.model.AddElement(companyType);

            this.peopleSet = new EdmEntitySet(defaultContainer, "People", personType);
            this.companySet = new EdmEntitySet(defaultContainer, "Companys", companyType);
            this.employeeSet = new EdmEntitySet(defaultContainer, "Employees", employeeType);
            defaultContainer.AddElement(this.employeeSet);
            defaultContainer.AddElement(this.peopleSet);
            defaultContainer.AddElement(this.companySet);

            var associatedCompanyNavigation = employeeType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "AssociatedCompany",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            employeeSet.AddNavigationTarget(associatedCompanyNavigation, companySet);
        }
コード例 #23
0
ファイル: TestModels.cs プロジェクト: AlineGuan/odata.net
        /// <summary>
        /// Creates a test model shared among parameter reader/writer tests.
        /// </summary>
        /// <returns>Returns a model with function imports.</returns>
        public static IEdmModel BuildModelWithFunctionImport()
        {
            EdmCoreModel coreModel = EdmCoreModel.Instance;
            EdmModel model = new EdmModel();
            const string defaultNamespaceName = "TestModel";
            EdmEntityContainer container = new EdmEntityContainer(defaultNamespaceName, "TestContainer");
            model.AddElement(container);

            EdmComplexType complexType = new EdmComplexType(defaultNamespaceName, "ComplexType");
            complexType.AddProperty(new EdmStructuralProperty(complexType, "PrimitiveProperty", coreModel.GetString(false)));
            complexType.AddProperty(new EdmStructuralProperty(complexType, "ComplexProperty", complexType.ToTypeReference(false)));
            model.AddElement(complexType);

            EdmEnumType enumType = new EdmEnumType(defaultNamespaceName, "EnumType");
            model.AddElement(enumType);

            EdmEntityType entityType = new EdmEntityType(defaultNamespaceName, "EntityType");
            entityType.AddKeys(new IEdmStructuralProperty[] {new EdmStructuralProperty(entityType, "ID", coreModel.GetInt32(false))});
            entityType.AddProperty(new EdmStructuralProperty(entityType, "ComplexProperty", complexType.ToTypeReference()));

            container.AddActionAndActionImport(model, "FunctionImport_Primitive", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("primitive", coreModel.GetString(false));
            container.AddActionAndActionImport(model, "FunctionImport_NullablePrimitive", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("nullablePrimitive", coreModel.GetString(true));
            EdmCollectionType stringCollectionType = new EdmCollectionType(coreModel.GetString(true));
            container.AddActionAndActionImport(model, "FunctionImport_PrimitiveCollection", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("primitiveCollection", stringCollectionType.ToTypeReference(false));
            container.AddActionAndActionImport(model, "FunctionImport_Complex", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("complex", complexType.ToTypeReference(true));
            EdmCollectionType complexCollectionType = new EdmCollectionType(complexType.ToTypeReference());
            container.AddActionAndActionImport(model, "FunctionImport_ComplexCollection", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("complexCollection", complexCollectionType.ToTypeReference());
            container.AddActionAndActionImport(model, "FunctionImport_Entry", null /*returnType*/, null /*entitySet*/, true /*bindable*/).Action.AsEdmAction().AddParameter("entry", entityType.ToTypeReference());
            EdmCollectionType entityCollectionType = new EdmCollectionType(entityType.ToTypeReference());
            container.AddActionAndActionImport(model, "FunctionImport_Feed", null /*returnType*/, null /*entitySet*/, true /*bindable*/).Action.AsEdmAction().AddParameter("feed", entityCollectionType.ToTypeReference());
            container.AddActionAndActionImport(model, "FunctionImport_Stream", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("stream", coreModel.GetStream(false));
            container.AddActionAndActionImport(model, "FunctionImport_Enum", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("enum", enumType.ToTypeReference());

            var functionImport_PrimitiveTwoParameters = container.AddActionAndActionImport(model, "FunctionImport_PrimitiveTwoParameters", null /*returnType*/, null /*entitySet*/, false /*bindable*/);
            functionImport_PrimitiveTwoParameters.Action.AsEdmAction().AddParameter("p1", coreModel.GetInt32(false));
            functionImport_PrimitiveTwoParameters.Action.AsEdmAction().AddParameter("p2", coreModel.GetString(false));

            container.AddActionAndActionImport(model, "FunctionImport_Int", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("p1", coreModel.GetInt32(false));
            container.AddActionAndActionImport(model, "FunctionImport_Double", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("p1", coreModel.GetDouble(false));
            EdmCollectionType int32CollectionType = new EdmCollectionType(coreModel.GetInt32(false));
            container.AddActionAndActionImport(model, "FunctionImport_NonNullablePrimitiveCollection", null /*returnType*/, null /*entitySet*/, false /*bindable*/).Action.AsEdmAction().AddParameter("p1", int32CollectionType.ToTypeReference(false));

            EdmComplexType complexType2 = new EdmComplexType(defaultNamespaceName, "ComplexTypeWithNullableProperties");
            complexType2.AddProperty(new EdmStructuralProperty(complexType2, "StringProperty", coreModel.GetString(true)));
            complexType2.AddProperty(new EdmStructuralProperty(complexType2, "IntegerProperty", coreModel.GetInt32(true)));
            model.AddElement(complexType2);

            var functionImport_MultipleNullableParameters = container.AddActionAndActionImport(model, "FunctionImport_MultipleNullableParameters", null /*returnType*/, null /*entitySet*/, false /*bindable*/);
            var function_MultipleNullableParameters = functionImport_MultipleNullableParameters.Action.AsEdmAction();
            function_MultipleNullableParameters.AddParameter("p1", coreModel.GetBinary(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p2", coreModel.GetBoolean(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p3", coreModel.GetByte(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p5", coreModel.GetDateTimeOffset(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p6", coreModel.GetDecimal(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p7", coreModel.GetDouble(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p8", coreModel.GetGuid(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p9", coreModel.GetInt16(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p10", coreModel.GetInt32(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p11", coreModel.GetInt64(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p12", coreModel.GetSByte(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p13", coreModel.GetSingle(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p14", coreModel.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p15", coreModel.GetString(true /*isNullable*/));
            function_MultipleNullableParameters.AddParameter("p16", complexType2.ToTypeReference(true /*isNullable*/));

            return model;
        }
コード例 #24
0
        public void TestElementInterfaceCriticalEntityTypeBaseType()
        {
            var expectedErrors = new EdmLibTestErrors()
            {
                { null, null, EdmErrorCode.InterfaceCriticalNavigationPartnerInvalid }
            };

            var baseEntity = new EdmEntityType("DefaultNamespace", "baseEntity");
            var entity2 = new EdmEntityType("DefaultNamespace", "Entity2");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = baseEntity,
                Type = new EdmEntityTypeReference(entity2, false)
            };

            navProperty.Partner = navProperty;
            baseEntity.AddProperty(navProperty);

            this.ValidateElement(baseEntity, expectedErrors);

            var entity = new EdmEntityType("DefaultNamespace", "Entity1", baseEntity);
            expectedErrors = new EdmLibTestErrors();
            this.ValidateElement(entity, expectedErrors);
        }
コード例 #25
0
        public void WriteOpenEntry()
        {
            EdmEntityType entityType = new EdmEntityType("NS", "Entity", null, false, true);
            IEdmStructuralProperty keyProp = new EdmStructuralProperty(entityType, "Id", EdmCoreModel.Instance.GetInt32(false));
            entityType.AddProperty(keyProp);
            entityType.AddKeys(keyProp);

            EdmOperation operation = new EdmFunction("NS", "Foo", EdmCoreModel.Instance.GetInt16(true));
            operation.AddParameter("entry", new EdmEntityTypeReference(entityType, false));

            Action<ODataJsonLightOutputContext> test = outputContext =>
            {
                var entry = new ODataEntry();
                entry.Properties = new List<ODataProperty>() { new ODataProperty() { Name = "ID", Value = 1 }, new ODataProperty() { Name = "DynamicProperty", Value = "DynamicValue" } };

                var parameterWriter = new ODataJsonLightParameterWriter(outputContext, operation);
                parameterWriter.WriteStart();
                var entryWriter = parameterWriter.CreateEntryWriter("entry");
                entryWriter.WriteStart(entry);
                entryWriter.WriteEnd();
                parameterWriter.WriteEnd();
                parameterWriter.Flush();
            };

            WriteAndValidate(test, "{\"entry\":{\"ID\":1,\"DynamicProperty\":\"DynamicValue\"}}", writingResponse: false);
        }
コード例 #26
0
        public void ValidateKindsOfNone()
        {
            StubEdmModel model = new StubEdmModel();
            EdmEntityContainer container = new EdmEntityContainer("namespace", "container");
            model.Add(container);

            model.Add(new NoneKinds1("namespace", "badThing", container));
            var type = new EdmEntityType("namespace", "type");
            type.AddProperty(new NoneKinds2("namespace", "otherBadThing", EdmCoreModel.Instance.GetInt32(false), type));
            model.Add(type);

            var expectedErrors = new EdmLibTestErrors()
            {
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds1)", EdmErrorCode.TypeMustNotHaveKindOfNone },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds1)", EdmErrorCode.TermMustNotHaveKindOfNone },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds1)", EdmErrorCode.EntityContainerElementMustNotHaveKindOfNone },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds1)", EdmErrorCode.SchemaElementMustNotHaveKindOfNone },
                { "(namespace.type)", EdmErrorCode.KeyMissingOnEntityType },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds2)", EdmErrorCode.PrimitiveTypeMustNotHaveKindOfNone },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds2)", EdmErrorCode.SchemaElementMustNotHaveKindOfNone },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds2)", EdmErrorCode.TypeMustNotHaveKindOfNone },
                { "(EdmLibTests.FunctionalTests.CodeCoverageBoostingTests+NoneKinds2)", EdmErrorCode.PropertyMustNotHaveKindOfNone },
            };
            this.VerifySemanticValidation(model, expectedErrors);

        }
コード例 #27
0
        public static IEdmModel CreateODataServiceModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "InMemoryEntities");
            model.AddElement(defaultContainer);

            #region ComplexType
            var addressType = new EdmComplexType(ns, "Address");
            addressType.AddProperty(new EdmStructuralProperty(addressType, "Street", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "City", EdmCoreModel.Instance.GetString(false)));
            addressType.AddProperty(new EdmStructuralProperty(addressType, "PostalCode", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(addressType);

            var homeAddressType = new EdmComplexType(ns, "HomeAddress", addressType, false);
            homeAddressType.AddProperty(new EdmStructuralProperty(homeAddressType, "FamilyName", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(homeAddressType);

            var companyAddressType = new EdmComplexType(ns, "CompanyAddress", addressType, false);
            companyAddressType.AddProperty(new EdmStructuralProperty(companyAddressType, "CompanyName", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(companyAddressType);

            var cityInformationType = new EdmComplexType(ns, "CityInformation");
            cityInformationType.AddProperty(new EdmStructuralProperty(cityInformationType, "CountryRegion", EdmCoreModel.Instance.GetString(false)));
            cityInformationType.AddProperty(new EdmStructuralProperty(cityInformationType, "IsCapital", EdmCoreModel.Instance.GetBoolean(false)));
            model.AddElement(cityInformationType);
            #endregion

            #region EnumType
            var accessLevelType = new EdmEnumType(ns, "AccessLevel", isFlags: true);
            accessLevelType.AddMember("None", new EdmIntegerConstant(0));
            accessLevelType.AddMember("Read", new EdmIntegerConstant(1));
            accessLevelType.AddMember("Write", new EdmIntegerConstant(2));
            accessLevelType.AddMember("Execute", new EdmIntegerConstant(4));
            accessLevelType.AddMember("ReadWrite", new EdmIntegerConstant(3));
            model.AddElement(accessLevelType);

            var colorType = new EdmEnumType(ns, "Color", isFlags: false);
            colorType.AddMember("Red", new EdmIntegerConstant(1));
            colorType.AddMember("Green", new EdmIntegerConstant(2));
            colorType.AddMember("Blue", new EdmIntegerConstant(4));
            model.AddElement(colorType);

            var companyCategory = new EdmEnumType(ns, "CompanyCategory", isFlags: false);
            companyCategory.AddMember("IT", new EdmIntegerConstant(0));
            companyCategory.AddMember("Communication", new EdmIntegerConstant(1));
            companyCategory.AddMember("Electronics", new EdmIntegerConstant(2));
            companyCategory.AddMember("Others", new EdmIntegerConstant(4));
            model.AddElement(companyCategory);
            #endregion

            #region Term
            model.AddElement(new EdmTerm(ns, "IsBoss", EdmCoreModel.Instance.GetBoolean(true), "Entity"));
            model.AddElement(new EdmTerm(ns, "AddressType", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(new EdmTerm(ns, "CityInfo", new EdmComplexTypeReference(cityInformationType, false)));
            model.AddElement(new EdmTerm(ns, "DisplayName", EdmCoreModel.Instance.GetString(true)));
            #endregion

            var personType = new EdmEntityType(ns, "Person");
            var personIdProperty = new EdmStructuralProperty(personType, "PersonID", EdmCoreModel.Instance.GetInt32(false));
            personType.AddProperty(personIdProperty);
            personType.AddKeys(new IEdmStructuralProperty[] { personIdProperty });
            personType.AddProperty(new EdmStructuralProperty(personType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "LastName", EdmCoreModel.Instance.GetString(false)));
            personType.AddProperty(new EdmStructuralProperty(personType, "MiddleName", EdmCoreModel.Instance.GetString(true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "HomeAddress", new EdmComplexTypeReference(addressType, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Home", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true)));
            personType.AddProperty(new EdmStructuralProperty(personType, "Numbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false)))));
            personType.AddProperty(new EdmStructuralProperty(personType, "Emails", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true)))));

            model.AddElement(personType);
            var personSet = new EdmEntitySet(defaultContainer, "People", personType);
            defaultContainer.AddElement(personSet);
            var boss = new EdmSingleton(defaultContainer, "Boss", personType);
            defaultContainer.AddElement(boss);

            var customerType = new EdmEntityType(ns, "Customer", personType);
            customerType.AddProperty(new EdmStructuralProperty(customerType, "City", EdmCoreModel.Instance.GetString(false)));
            customerType.AddProperty(new EdmStructuralProperty(customerType, "Birthday", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            customerType.AddProperty(new EdmStructuralProperty(customerType, "TimeBetweenLastTwoOrders", EdmCoreModel.Instance.GetDuration(false)));
            model.AddElement(customerType);
            var customerSet = new EdmEntitySet(defaultContainer, "Customers", customerType);
            defaultContainer.AddElement(customerSet);

            EdmSingleton vipCustomer = new EdmSingleton(defaultContainer, "VipCustomer", customerType);
            defaultContainer.AddElement(vipCustomer);

            var employeeType = new EdmEntityType(ns, "Employee", personType);
            employeeType.AddProperty(new EdmStructuralProperty(employeeType, "DateHired", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            employeeType.AddProperty(new EdmStructuralProperty(employeeType, "Office", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true)));
            model.AddElement(employeeType);
            var employeeSet = new EdmEntitySet(defaultContainer, "Employees", employeeType);
            defaultContainer.AddElement(employeeSet);

            var productType = new EdmEntityType(ns, "Product");
            var productIdProperty = new EdmStructuralProperty(productType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            productType.AddProperty(productIdProperty);
            productType.AddKeys(productIdProperty);
            productType.AddProperty(new EdmStructuralProperty(productType, "Name", EdmCoreModel.Instance.GetString(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "QuantityPerUnit", EdmCoreModel.Instance.GetString(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "UnitPrice", EdmCoreModel.Instance.GetSingle(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "QuantityInStock", EdmCoreModel.Instance.GetInt32(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "Discontinued", EdmCoreModel.Instance.GetBoolean(false)));
            productType.AddProperty(new EdmStructuralProperty(productType, "UserAccess", new EdmEnumTypeReference(accessLevelType, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "SkinColor", new EdmEnumTypeReference(colorType, true)));
            productType.AddProperty(new EdmStructuralProperty(productType, "CoverColors", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEnumTypeReference(colorType, false)))));
            model.AddElement(productType);
            var productSet = new EdmEntitySet(defaultContainer, "Products", productType);
            defaultContainer.AddElement(productSet);

            var productDetailType = new EdmEntityType(ns, "ProductDetail");
            var productDetailIdProperty1 = new EdmStructuralProperty(productDetailType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            var productDetailIdProperty2 = new EdmStructuralProperty(productDetailType, "ProductDetailID", EdmCoreModel.Instance.GetInt32(false));
            productDetailType.AddProperty(productDetailIdProperty1);
            productDetailType.AddKeys(productDetailIdProperty1);
            productDetailType.AddProperty(productDetailIdProperty2);
            productDetailType.AddKeys(productDetailIdProperty2);
            productDetailType.AddProperty(new EdmStructuralProperty(productDetailType, "ProductName", EdmCoreModel.Instance.GetString(false)));
            productDetailType.AddProperty(new EdmStructuralProperty(productDetailType, "Description", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(productDetailType);
            var productDetailSet = new EdmEntitySet(defaultContainer, "ProductDetails", productDetailType);
            defaultContainer.AddElement(productDetailSet);

            var productReviewType = new EdmEntityType(ns, "ProductReview");
            var productReviewIdProperty1 = new EdmStructuralProperty(productReviewType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            var productReviewIdProperty2 = new EdmStructuralProperty(productReviewType, "ProductDetailID", EdmCoreModel.Instance.GetInt32(false));
            var productReviewIdProperty3 = new EdmStructuralProperty(productReviewType, "ReviewTitle", EdmCoreModel.Instance.GetString(false));
            var productReviewIdProperty4 = new EdmStructuralProperty(productReviewType, "RevisionID", EdmCoreModel.Instance.GetInt32(false));
            productReviewType.AddProperty(productReviewIdProperty1);
            productReviewType.AddKeys(productReviewIdProperty1);
            productReviewType.AddProperty(productReviewIdProperty2);
            productReviewType.AddKeys(productReviewIdProperty2);
            productReviewType.AddProperty(productReviewIdProperty3);
            productReviewType.AddKeys(productReviewIdProperty3);
            productReviewType.AddProperty(productReviewIdProperty4);
            productReviewType.AddKeys(productReviewIdProperty4);
            productReviewType.AddProperty(new EdmStructuralProperty(productReviewType, "Comment", EdmCoreModel.Instance.GetString(false)));
            productReviewType.AddProperty(new EdmStructuralProperty(productReviewType, "Author", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(productReviewType);
            var productReviewSet = new EdmEntitySet(defaultContainer, "ProductReviews", productReviewType);
            defaultContainer.AddElement(productReviewSet);

            var abstractType = new EdmEntityType(ns, "AbstractEntity", null, true, false);
            model.AddElement(abstractType);

            var orderType = new EdmEntityType(ns, "Order", abstractType);
            var orderIdProperty = new EdmStructuralProperty(orderType, "OrderID", EdmCoreModel.Instance.GetInt32(false));
            orderType.AddProperty(orderIdProperty);
            orderType.AddKeys(orderIdProperty);
            orderType.AddProperty(new EdmStructuralProperty(orderType, "OrderDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "ShelfLife", EdmCoreModel.Instance.GetDuration(true)));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "OrderShelfLifes", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDuration(true)))));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "ShipDate", EdmCoreModel.Instance.GetDate(false)));
            orderType.AddProperty(new EdmStructuralProperty(orderType, "ShipTime", EdmCoreModel.Instance.GetTimeOfDay(false)));

            model.AddElement(orderType);
            var orderSet = new EdmEntitySet(defaultContainer, "Orders", orderType);
            defaultContainer.AddElement(orderSet);

            var orderDetailType = new EdmEntityType(ns, "OrderDetail", abstractType);
            var orderId = new EdmStructuralProperty(orderDetailType, "OrderID", EdmCoreModel.Instance.GetInt32(false));
            orderDetailType.AddProperty(orderId);
            orderDetailType.AddKeys(orderId);
            var productId = new EdmStructuralProperty(orderDetailType, "ProductID", EdmCoreModel.Instance.GetInt32(false));
            orderDetailType.AddProperty(productId);
            orderDetailType.AddKeys(productId);
            orderDetailType.AddProperty(new EdmStructuralProperty(orderDetailType, "OrderPlaced", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            orderDetailType.AddProperty(new EdmStructuralProperty(orderDetailType, "Quantity", EdmCoreModel.Instance.GetInt32(false)));
            orderDetailType.AddProperty(new EdmStructuralProperty(orderDetailType, "UnitPrice", EdmCoreModel.Instance.GetSingle(false)));

            model.AddElement(orderDetailType);
            var orderDetailSet = new EdmEntitySet(defaultContainer, "OrderDetails", orderDetailType);
            defaultContainer.AddElement(orderDetailSet);

            var parentNavigation = personType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Parent",
                Target = personType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var productOrderedNavigation = orderDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "ProductOrdered",
                Target = productType,
                TargetMultiplicity = EdmMultiplicity.Many
            });

            var associatedOrderNavigation = orderDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "AssociatedOrder",
                Target = orderType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var loggedInEmployeeNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "LoggedInEmployee",
                Target = employeeType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var customerForOrderNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "CustomerForOrder",
                Target = customerType,
                TargetMultiplicity = EdmMultiplicity.One
            });
            var orderDetailsNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "OrderDetails",
                Target = orderDetailType,
                TargetMultiplicity = EdmMultiplicity.Many
            });
            var ordersNavigation = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Orders",
                Target = orderType,
                TargetMultiplicity = EdmMultiplicity.Many
            });
            var productProductDetailNavigation = productType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Details",
                TargetMultiplicity = EdmMultiplicity.Many,
                Target = productDetailType,
                DependentProperties = new List<IEdmStructuralProperty>()
                    {
                        productIdProperty
                    },
                PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        productDetailIdProperty1
                    }
            });
            var productDetailProductNavigation = productDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "RelatedProduct",
                Target = productType,
                TargetMultiplicity = EdmMultiplicity.ZeroOrOne
            });
            var productDetailProductReviewNavigation = productDetailType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Reviews",
                TargetMultiplicity = EdmMultiplicity.Many,
                Target = productReviewType,
                DependentProperties = new List<IEdmStructuralProperty>()
                    {
                        productDetailIdProperty1, 
                        productDetailIdProperty2,
                    },
                PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        productReviewIdProperty1, 
                        productReviewIdProperty2
                    }
            });

            model.SetCoreChangeTrackingAnnotation(orderSet, new EdmStructuralProperty[] { orderIdProperty }, new EdmNavigationProperty[] { orderDetailsNavigation });

            ((EdmEntitySet)personSet).AddNavigationTarget(parentNavigation, personSet);
            ((EdmEntitySet)orderDetailSet).AddNavigationTarget(associatedOrderNavigation, orderSet);
            ((EdmEntitySet)orderDetailSet).AddNavigationTarget(productOrderedNavigation, productSet);
            ((EdmEntitySet)customerSet).AddNavigationTarget(ordersNavigation, orderSet);
            ((EdmEntitySet)customerSet).AddNavigationTarget(parentNavigation, personSet);
            ((EdmEntitySet)employeeSet).AddNavigationTarget(parentNavigation, personSet);
            ((EdmEntitySet)orderSet).AddNavigationTarget(loggedInEmployeeNavigation, employeeSet);
            ((EdmEntitySet)orderSet).AddNavigationTarget(customerForOrderNavigation, customerSet);
            ((EdmEntitySet)orderSet).AddNavigationTarget(orderDetailsNavigation, orderDetailSet);
            ((EdmEntitySet)productSet).AddNavigationTarget(productProductDetailNavigation, productDetailSet);
            ((EdmEntitySet)productDetailSet).AddNavigationTarget(productDetailProductNavigation, productSet);
            ((EdmEntitySet)productDetailSet).AddNavigationTarget(productDetailProductReviewNavigation, productReviewSet);

            #region Singleton

            var departmentType = new EdmEntityType(ns, "Department", null);
            var departmentId = new EdmStructuralProperty(departmentType, "DepartmentID", EdmCoreModel.Instance.GetInt32(false));
            departmentType.AddProperty(departmentId);
            departmentType.AddKeys(departmentId);
            departmentType.AddProperty(new EdmStructuralProperty(departmentType, "Name", EdmCoreModel.Instance.GetString(false)));
            departmentType.AddProperty(new EdmStructuralProperty(departmentType, "DepartmentNO", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(departmentType);
            EdmEntitySet departments = new EdmEntitySet(defaultContainer, "Departments", departmentType);
            defaultContainer.AddElement(departments);

            var companyType = new EdmEntityType(ns, "Company", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ true);
            var companyId = new EdmStructuralProperty(companyType, "CompanyID", EdmCoreModel.Instance.GetInt32(false));
            companyType.AddProperty(companyId);
            companyType.AddKeys(companyId);
            companyType.AddProperty(new EdmStructuralProperty(companyType, "CompanyCategory", new EdmEnumTypeReference(companyCategory, true)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Revenue", EdmCoreModel.Instance.GetInt64(false)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Name", EdmCoreModel.Instance.GetString(true)));
            companyType.AddProperty(new EdmStructuralProperty(companyType, "Address", new EdmComplexTypeReference(addressType, true)));

            model.AddElement(companyType);
            EdmSingleton company = new EdmSingleton(defaultContainer, "Company", companyType);
            defaultContainer.AddElement(company);

            var publicCompanyType = new EdmEntityType(ns, "PublicCompany", /*baseType*/ companyType, /*isAbstract*/ false, /*isOpen*/ true);
            publicCompanyType.AddProperty(new EdmStructuralProperty(publicCompanyType, "StockExchange", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(publicCompanyType);
            EdmSingleton publicCompany = new EdmSingleton(defaultContainer, "PublicCompany", companyType);
            defaultContainer.AddElement(publicCompany);

            var assetType = new EdmEntityType(ns, "Asset", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ false);
            var assetId = new EdmStructuralProperty(assetType, "AssetID", EdmCoreModel.Instance.GetInt32(false));
            assetType.AddProperty(assetId);
            assetType.AddKeys(assetId);
            assetType.AddProperty(new EdmStructuralProperty(assetType, "Name", EdmCoreModel.Instance.GetString(true)));
            assetType.AddProperty(new EdmStructuralProperty(assetType, "Number", EdmCoreModel.Instance.GetInt32(false)));
            model.AddElement(assetType);

            var clubType = new EdmEntityType(ns, "Club", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ false);
            var clubId = new EdmStructuralProperty(clubType, "ClubID", EdmCoreModel.Instance.GetInt32(false));
            clubType.AddProperty(clubId);
            clubType.AddKeys(clubId);
            clubType.AddProperty(new EdmStructuralProperty(clubType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(clubType);

            var labourUnionType = new EdmEntityType(ns, "LabourUnion", /*baseType*/ null, /*isAbstract*/ false, /*isOpen*/ false);
            var labourUnionId = new EdmStructuralProperty(labourUnionType, "LabourUnionID", EdmCoreModel.Instance.GetInt32(false));
            labourUnionType.AddProperty(labourUnionId);
            labourUnionType.AddKeys(labourUnionId);
            labourUnionType.AddProperty(new EdmStructuralProperty(labourUnionType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(labourUnionType);
            EdmSingleton labourUnion = new EdmSingleton(defaultContainer, "LabourUnion", labourUnionType);
            defaultContainer.AddElement(labourUnion);

            var companyEmployeeNavigation = companyType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Employees",
                Target = employeeType,
                TargetMultiplicity = EdmMultiplicity.Many
            }, new EdmNavigationPropertyInfo()
            {
                Name = "Company",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var companyCustomerNavigation = companyType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "VipCustomer",
                Target = customerType,
                TargetMultiplicity = EdmMultiplicity.One
            }, new EdmNavigationPropertyInfo()
            {
                Name = "Company",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var companyDepartmentsNavigation = companyType.AddBidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Departments",
                Target = departmentType,
                TargetMultiplicity = EdmMultiplicity.Many
            },
            new EdmNavigationPropertyInfo()
            {
                Name = "Company",
                Target = companyType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var companyCoreDepartmentNavigation = companyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "CoreDepartment",
                Target = departmentType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            var publicCompanyAssetNavigation = publicCompanyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Assets",
                Target = assetType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var publicCompanyClubNavigation = publicCompanyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "Club",
                Target = clubType,
                TargetMultiplicity = EdmMultiplicity.One,
                ContainsTarget = true
            });

            var publicCompanyLabourUnionNavigation = publicCompanyType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "LabourUnion",
                Target = labourUnionType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            //vipCustomer->orders
            ((EdmSingleton)vipCustomer).AddNavigationTarget(ordersNavigation, orderSet);
            //vipCustomer->people
            ((EdmSingleton)vipCustomer).AddNavigationTarget(parentNavigation, personSet);
            ((EdmSingleton)boss).AddNavigationTarget(parentNavigation, personSet);
            //employeeSet<->company
            ((EdmSingleton)company).AddNavigationTarget(companyEmployeeNavigation, employeeSet);
            ((EdmEntitySet)employeeSet).AddNavigationTarget(companyEmployeeNavigation.Partner, company);
            //company<->vipcustomer
            ((EdmSingleton)company).AddNavigationTarget(companyCustomerNavigation, vipCustomer);
            ((EdmSingleton)vipCustomer).AddNavigationTarget(companyCustomerNavigation.Partner, company);
            //company<->departments
            ((EdmSingleton)company).AddNavigationTarget(companyDepartmentsNavigation, departments);
            ((EdmEntitySet)departments).AddNavigationTarget(companyDepartmentsNavigation.Partner, company);
            //company<-> Single department
            ((EdmSingleton)company).AddNavigationTarget(companyCoreDepartmentNavigation, departments);
            //publicCompany<-> Singleton
            ((EdmSingleton)publicCompany).AddNavigationTarget(publicCompanyLabourUnionNavigation, labourUnion);

            #region Action/Function
            //Bound Action : bound to Entity, return EnumType
            var productAddAccessRightAction = new EdmAction(ns, "AddAccessRight", new EdmEnumTypeReference(accessLevelType, true), true, null);
            productAddAccessRightAction.AddParameter("product", new EdmEntityTypeReference(productType, false));
            productAddAccessRightAction.AddParameter("accessRight", new EdmEnumTypeReference(accessLevelType, true));
            model.AddElement(productAddAccessRightAction);

            //Bound Action : Bound to Singleton, Primitive Parameter return Primitive Type
            EdmAction increaseRevenue = new EdmAction(ns, "IncreaseRevenue", EdmCoreModel.Instance.GetInt64(false), /*isBound*/true, /*entitySetPathExpression*/null);
            increaseRevenue.AddParameter(new EdmOperationParameter(increaseRevenue, "p", new EdmEntityTypeReference(companyType, false)));
            increaseRevenue.AddParameter(new EdmOperationParameter(increaseRevenue, "IncreaseValue", EdmCoreModel.Instance.GetInt64(true)));
            model.AddElement(increaseRevenue);

            //Bound Action : Bound to Entity, Collection Of ComplexType Parameter, Return Entity
            var resetAddressAction = new EdmAction(ns, "ResetAddress", new EdmEntityTypeReference(personType, false), true, new EdmPathExpression("person"));
            resetAddressAction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            resetAddressAction.AddParameter("addresses", new EdmCollectionTypeReference(new EdmCollectionType(new EdmComplexTypeReference(addressType, true))));
            resetAddressAction.AddParameter("index", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(resetAddressAction);

            //Bound Action : Bound to Entity, EntityType Parameter, Return Entity
            var placeOrderAction = new EdmAction(ns, "PlaceOrder", new EdmEntityTypeReference(orderType, false), true, new EdmPathExpression("customer/Orders"));
            placeOrderAction.AddParameter("customer", new EdmEntityTypeReference(customerType, false));
            placeOrderAction.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            model.AddElement(placeOrderAction);

            //Bound Action : Bound to Entity, Collection Of EntityType Parameter, Return Collection of Entity
            var placeOrdersAction = new EdmAction(ns, "PlaceOrders", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(orderType, false))), true, new EdmPathExpression("customer/Orders"));
            placeOrdersAction.AddParameter("customer", new EdmEntityTypeReference(customerType, false));
            placeOrdersAction.AddParameter("orders", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(orderType, false))));
            model.AddElement(placeOrdersAction);

            //Bound Action : Bound to collection of EntitySet, Return Collection of Entity
            var discountSeveralProductAction = new EdmAction(ns, "Discount",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productType, false))), true, new EdmPathExpression("products"));
            discountSeveralProductAction.AddParameter("products", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productType, false))));
            discountSeveralProductAction.AddParameter("percentage", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(discountSeveralProductAction);

            //Bound Action : Bound to Entity, return void
            var changeLabourUnionNameAction = new EdmAction(ns, "ChangeLabourUnionName", null, true, null);
            changeLabourUnionNameAction.AddParameter("labourUnion", new EdmEntityTypeReference(labourUnionType, false));
            changeLabourUnionNameAction.AddParameter("name", EdmCoreModel.Instance.GetString(true));
            model.AddElement(changeLabourUnionNameAction);

            //Bound Action : Bound to Entity, return order take Date/TimeOfDay as Parameter
            var changeShipTimeAndDate = new EdmAction(ns, "ChangeShipTimeAndDate", new EdmEntityTypeReference(orderType, false), true, new EdmPathExpression("order"));
            changeShipTimeAndDate.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            changeShipTimeAndDate.AddParameter("date", EdmCoreModel.Instance.GetDate(false));
            changeShipTimeAndDate.AddParameter("time", EdmCoreModel.Instance.GetTimeOfDay(false));
            model.AddElement(changeShipTimeAndDate);

            //UnBound Action : Primitive parameter, Return void
            var discountAction = new EdmAction(ns, "Discount", null, false, null);
            discountAction.AddParameter("percentage", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(discountAction);
            defaultContainer.AddActionImport(discountAction);

            //UnBound Action : Collection of Primitive parameter, Return Collection of Primitive
            var resetBossEmailAction = new EdmAction(ns, "ResetBossEmail", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))), false, null);
            resetBossEmailAction.AddParameter("emails", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))));
            model.AddElement(resetBossEmailAction);
            defaultContainer.AddActionImport(resetBossEmailAction);

            //UnBound Action : ComplexType parameter, Return ComplexType
            var resetBossAddressAction = new EdmAction(ns, "ResetBossAddress", new EdmComplexTypeReference(addressType, false), false, null);
            resetBossAddressAction.AddParameter("address", new EdmComplexTypeReference(addressType, false));
            model.AddElement(resetBossAddressAction);
            defaultContainer.AddActionImport(resetBossAddressAction);

            //UnBound Action: ResetDataSource
            var resetDataSourceAction = new EdmAction(ns, "ResetDataSource", null, false, null);
            model.AddElement(resetDataSourceAction);
            defaultContainer.AddActionImport(resetDataSourceAction);

            //Bound Function : Bound to Singleton, Return PrimitiveType
            EdmFunction getCompanyEmployeeCount = new EdmFunction(ns, "GetEmployeesCount", EdmCoreModel.Instance.GetInt32(false), /*isBound*/true, /*entitySetPathExpression*/null, /*isComposable*/false);
            getCompanyEmployeeCount.AddParameter(new EdmOperationParameter(getCompanyEmployeeCount, "p", new EdmEntityTypeReference(companyType, false)));
            model.AddElement(getCompanyEmployeeCount);

            //Bound Function : Bound to Entity, Return CollectionOfEntity
            var getProductDetailsFunction = new EdmFunction(ns, "GetProductDetails",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productDetailType, false))),
                true, new EdmPathExpression("product/Details"), true);
            getProductDetailsFunction.AddParameter("product", new EdmEntityTypeReference(productType, false));
            getProductDetailsFunction.AddParameter("count", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(getProductDetailsFunction);

            //Bound Function : Bound to Entity, Return Entity
            var getRelatedProductFunction = new EdmFunction(ns, "GetRelatedProduct",
                new EdmEntityTypeReference(productType, false),
                true, new EdmPathExpression("productDetail/RelatedProduct"), true);
            getRelatedProductFunction.AddParameter("productDetail", new EdmEntityTypeReference(productDetailType, false));
            model.AddElement(getRelatedProductFunction);

            //Bound Function : Bound to Entity, Return Collection of Abstract Entity
            var getOrderAndOrderDetails = new EdmFunction(ns, "getOrderAndOrderDetails",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(abstractType, false))),
                true, new EdmPathExpression("customer/Orders"), true);
            getOrderAndOrderDetails.AddParameter("customer", new EdmEntityTypeReference(customerType, false));
            model.AddElement(getOrderAndOrderDetails);

            //Bound Function : Bound to CollectionOfEntity, Return Entity
            var getSeniorEmployees = new EdmFunction(ns, "GetSeniorEmployees",
                new EdmEntityTypeReference(employeeType, true),
                true, new EdmPathExpression("employees"), true);
            getSeniorEmployees.AddParameter("employees", new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(employeeType, false))));
            model.AddElement(getSeniorEmployees);

            //Bound Function : Bound to Order, Return Edm.Date
            var getOrderShipDate = new EdmFunction(ns, "GetShipDate", EdmCoreModel.Instance.GetDate(false), true, null, false);
            getOrderShipDate.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            model.AddElement(getOrderShipDate);

            //Bound Function : Bound to Order, Return Edm.TimeOfDay
            var getOrderShipTime = new EdmFunction(ns, "GetShipTime", EdmCoreModel.Instance.GetTimeOfDay(false), true, null, false);
            getOrderShipTime.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            model.AddElement(getOrderShipTime);

            //Bound Function : Bound to Order, Parameter: Edm.TimeOfDay, Return Edm.Boolean
            var checkOrderShipTime = new EdmFunction(ns, "CheckShipTime", EdmCoreModel.Instance.GetBoolean(false), true, null, false);
            checkOrderShipTime.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            checkOrderShipTime.AddParameter("time", EdmCoreModel.Instance.GetTimeOfDay(false));
            model.AddElement(checkOrderShipTime);

            //Bound Function : Bound to Order, Parameter: Edm.Date, Return Edm.Boolean
            var checkOrderShipDate = new EdmFunction(ns, "CheckShipDate", EdmCoreModel.Instance.GetBoolean(false), true, null, false);
            checkOrderShipDate.AddParameter("order", new EdmEntityTypeReference(orderType, false));
            checkOrderShipDate.AddParameter("date", EdmCoreModel.Instance.GetDate(false));
            model.AddElement(checkOrderShipDate);

            //UnBound Function : Return EnumType
            var defaultColorFunction = new EdmFunction(ns, "GetDefaultColor", new EdmEnumTypeReference(colorType, true), false, null, true);
            model.AddElement(defaultColorFunction);
            defaultContainer.AddFunctionImport("GetDefaultColor", defaultColorFunction, null, true);

            //UnBound Function : Complex Parameter, Return Entity
            var getPersonFunction = new EdmFunction(ns, "GetPerson",
                new EdmEntityTypeReference(personType, false),
                false, null, true);
            getPersonFunction.AddParameter("address", new EdmComplexTypeReference(addressType, false));
            model.AddElement(getPersonFunction);
            defaultContainer.AddFunctionImport("GetPerson", getPersonFunction, new EdmEntitySetReferenceExpression(personSet), true);

            //UnBound Function : Primtive Parameter, Return Entity
            var getPersonFunction2 = new EdmFunction(ns, "GetPerson2",
                new EdmEntityTypeReference(personType, false),
                false, null, true);
            getPersonFunction2.AddParameter("city", EdmCoreModel.Instance.GetString(false));
            model.AddElement(getPersonFunction2);
            defaultContainer.AddFunctionImport("GetPerson2", getPersonFunction2, new EdmEntitySetReferenceExpression(personSet), true);

            //UnBound Function : Return CollectionOfEntity
            var getAllProductsFunction = new EdmFunction(ns, "GetAllProducts",
                new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(productType, false))),
                false, null, true);
            model.AddElement(getAllProductsFunction);
            defaultContainer.AddFunctionImport("GetAllProducts", getAllProductsFunction, new EdmEntitySetReferenceExpression(productSet), true);

            //UnBound Function : Multi ParameterS Return Collection Of ComplexType
            var getBossEmailsFunction = new EdmFunction(ns, "GetBossEmails",
                new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))),
                false, null, false);
            getBossEmailsFunction.AddParameter("start", EdmCoreModel.Instance.GetInt32(false));
            getBossEmailsFunction.AddParameter("count", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(getBossEmailsFunction);
            defaultContainer.AddFunctionImport(getBossEmailsFunction.Name, getBossEmailsFunction, null, true);

            var getProductsByAccessLevelFunction = new EdmFunction(ns, "GetProductsByAccessLevel",
                new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))),
                false, null, false);
            getProductsByAccessLevelFunction.AddParameter("accessLevel", new EdmEnumTypeReference(accessLevelType, false));
            model.AddElement(getProductsByAccessLevelFunction);
            defaultContainer.AddFunctionImport(getProductsByAccessLevelFunction.Name, getProductsByAccessLevelFunction, null, true);

            #endregion

            #endregion

            #region For containment

            var accountInfoType = new EdmComplexType(ns, "AccountInfo", null, false, true);
            accountInfoType.AddProperty(new EdmStructuralProperty(accountInfoType, "FirstName", EdmCoreModel.Instance.GetString(false)));
            accountInfoType.AddProperty(new EdmStructuralProperty(accountInfoType, "LastName", EdmCoreModel.Instance.GetString(false)));

            var accountType = new EdmEntityType(ns, "Account");
            var accountIdProperty = new EdmStructuralProperty(accountType, "AccountID", EdmCoreModel.Instance.GetInt32(false));
            accountType.AddProperty(accountIdProperty);
            accountType.AddKeys(accountIdProperty);
            accountType.AddProperty(new EdmStructuralProperty(accountType, "CountryRegion", EdmCoreModel.Instance.GetString(false)));
            accountType.AddProperty(new EdmStructuralProperty(accountType, "AccountInfo", new EdmComplexTypeReference(accountInfoType, true)));

            var giftCardType = new EdmEntityType(ns, "GiftCard");
            var giftCardIdProperty = new EdmStructuralProperty(giftCardType, "GiftCardID", EdmCoreModel.Instance.GetInt32(false));
            giftCardType.AddProperty(giftCardIdProperty);
            giftCardType.AddKeys(giftCardIdProperty);
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "GiftCardNO", EdmCoreModel.Instance.GetString(false)));
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "Amount", EdmCoreModel.Instance.GetDouble(false)));
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "ExperationDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));
            giftCardType.AddProperty(new EdmStructuralProperty(giftCardType, "OwnerName", EdmCoreModel.Instance.GetString(true)));


            var paymentInstrumentType = new EdmEntityType(ns, "PaymentInstrument");
            var paymentInstrumentIdProperty = new EdmStructuralProperty(paymentInstrumentType, "PaymentInstrumentID", EdmCoreModel.Instance.GetInt32(false));
            paymentInstrumentType.AddProperty(paymentInstrumentIdProperty);
            paymentInstrumentType.AddKeys(paymentInstrumentIdProperty);
            paymentInstrumentType.AddProperty(new EdmStructuralProperty(paymentInstrumentType, "FriendlyName", EdmCoreModel.Instance.GetString(false)));
            paymentInstrumentType.AddProperty(new EdmStructuralProperty(paymentInstrumentType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var creditCardType = new EdmEntityType(ns, "CreditCardPI", paymentInstrumentType);
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "CardNumber", EdmCoreModel.Instance.GetString(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "CVV", EdmCoreModel.Instance.GetString(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "HolderName", EdmCoreModel.Instance.GetString(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "Balance", EdmCoreModel.Instance.GetDouble(false)));
            creditCardType.AddProperty(new EdmStructuralProperty(creditCardType, "ExperationDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var storedPIType = new EdmEntityType(ns, "StoredPI");
            var storedPIIdProperty = new EdmStructuralProperty(storedPIType, "StoredPIID", EdmCoreModel.Instance.GetInt32(false));
            storedPIType.AddProperty(storedPIIdProperty);
            storedPIType.AddKeys(storedPIIdProperty);
            storedPIType.AddProperty(new EdmStructuralProperty(storedPIType, "PIName", EdmCoreModel.Instance.GetString(false)));
            storedPIType.AddProperty(new EdmStructuralProperty(storedPIType, "PIType", EdmCoreModel.Instance.GetString(false)));
            storedPIType.AddProperty(new EdmStructuralProperty(storedPIType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var statementType = new EdmEntityType(ns, "Statement");
            var statementIdProperty = new EdmStructuralProperty(statementType, "StatementID", EdmCoreModel.Instance.GetInt32(false));
            statementType.AddProperty(statementIdProperty);
            statementType.AddKeys(statementIdProperty);
            statementType.AddProperty(new EdmStructuralProperty(statementType, "TransactionType", EdmCoreModel.Instance.GetString(false)));
            statementType.AddProperty(new EdmStructuralProperty(statementType, "TransactionDescription", EdmCoreModel.Instance.GetString(false)));
            statementType.AddProperty(new EdmStructuralProperty(statementType, "Amount", EdmCoreModel.Instance.GetDouble(false)));

            var creditRecordType = new EdmEntityType(ns, "CreditRecord");
            var creditRecordIdProperty = new EdmStructuralProperty(creditRecordType, "CreditRecordID", EdmCoreModel.Instance.GetInt32(false));
            creditRecordType.AddProperty(creditRecordIdProperty);
            creditRecordType.AddKeys(creditRecordIdProperty);
            creditRecordType.AddProperty(new EdmStructuralProperty(creditRecordType, "IsGood", EdmCoreModel.Instance.GetBoolean(false)));
            creditRecordType.AddProperty(new EdmStructuralProperty(creditRecordType, "Reason", EdmCoreModel.Instance.GetString(false)));
            creditRecordType.AddProperty(new EdmStructuralProperty(creditRecordType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            var subscriptionType = new EdmEntityType(ns, "Subscription");
            var subscriptionIdProperty = new EdmStructuralProperty(subscriptionType, "SubscriptionID", EdmCoreModel.Instance.GetInt32(false));
            subscriptionType.AddProperty(subscriptionIdProperty);
            subscriptionType.AddKeys(subscriptionIdProperty);
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "TemplateGuid", EdmCoreModel.Instance.GetString(false)));
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "Title", EdmCoreModel.Instance.GetString(false)));
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "Category", EdmCoreModel.Instance.GetString(false)));
            subscriptionType.AddProperty(new EdmStructuralProperty(subscriptionType, "CreatedDate", EdmCoreModel.Instance.GetDateTimeOffset(false)));

            #region Functions/Actions
            var giftCardAmountFunction = new EdmFunction(ns, "GetActualAmount", EdmCoreModel.Instance.GetDouble(false), true, null, false);
            giftCardAmountFunction.AddParameter("giftcard", new EdmEntityTypeReference(giftCardType, false));
            giftCardAmountFunction.AddParameter("bonusRate", EdmCoreModel.Instance.GetDouble(true));
            model.AddElement(giftCardAmountFunction);

            var accountDefaultPIFunction = new EdmFunction(ns, "GetDefaultPI", new EdmEntityTypeReference(paymentInstrumentType, true), true, new EdmPathExpression("account/MyPaymentInstruments"), false);
            accountDefaultPIFunction.AddParameter("account", new EdmEntityTypeReference(accountType, false));
            model.AddElement(accountDefaultPIFunction);

            var accountRefreshDefaultPIAction = new EdmAction(ns, "RefreshDefaultPI", new EdmEntityTypeReference(paymentInstrumentType, true), true, new EdmPathExpression("account/MyPaymentInstruments"));
            accountRefreshDefaultPIAction.AddParameter("account", new EdmEntityTypeReference(accountType, false));
            accountRefreshDefaultPIAction.AddParameter("newDate", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(accountRefreshDefaultPIAction);

            //Bound Function : Bound to Entity, Return ComplexType
            var getHomeAddressFunction = new EdmFunction(ns, "GetHomeAddress",
                new EdmComplexTypeReference(homeAddressType, false),
                true, null, true);
            getHomeAddressFunction.AddParameter("person", new EdmEntityTypeReference(personType, false));
            model.AddElement(getHomeAddressFunction);

            //Bound Function : Bound to Entity, Return ComplexType
            var getAccountInfoFunction = new EdmFunction(ns, "GetAccountInfo",
                new EdmComplexTypeReference(accountInfoType, false),
                true, null, true);
            getAccountInfoFunction.AddParameter("account", new EdmEntityTypeReference(accountType, false));
            model.AddElement(getAccountInfoFunction);

            #endregion

            var accountGiftCardNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "MyGiftCard",
                Target = giftCardType,
                TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                ContainsTarget = true
            });

            var accountPIsNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "MyPaymentInstruments",
                Target = paymentInstrumentType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var accountActiveSubsNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "ActiveSubscriptions",
                Target = subscriptionType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var accountAvailableSubsTemplatesNavigation = accountType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "AvailableSubscriptionTemplatess",
                Target = subscriptionType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = false
            });

            var piStoredNavigation = paymentInstrumentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "TheStoredPI",
                Target = storedPIType,
                TargetMultiplicity = EdmMultiplicity.One,
                ContainsTarget = false
            });

            var piStatementsNavigation = paymentInstrumentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "BillingStatements",
                Target = statementType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            var piBackupStoredPINavigation = paymentInstrumentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "BackupStoredPI",
                Target = storedPIType,
                TargetMultiplicity = EdmMultiplicity.One,
                ContainsTarget = false
            });

            var creditCardCreditRecordNavigation = creditCardType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "CreditRecords",
                Target = creditRecordType,
                TargetMultiplicity = EdmMultiplicity.Many,
                ContainsTarget = true
            });

            model.AddElement(accountInfoType);
            model.AddElement(accountType);
            model.AddElement(giftCardType);
            model.AddElement(paymentInstrumentType);
            model.AddElement(creditCardType);
            model.AddElement(storedPIType);
            model.AddElement(statementType);
            model.AddElement(creditRecordType);
            model.AddElement(subscriptionType);

            var accountSet = new EdmEntitySet(defaultContainer, "Accounts", accountType);
            defaultContainer.AddElement(accountSet);
            var storedPISet = new EdmEntitySet(defaultContainer, "StoredPIs", storedPIType);
            defaultContainer.AddElement(storedPISet);
            var subscriptionTemplatesSet = new EdmEntitySet(defaultContainer, "SubscriptionTemplates", subscriptionType);
            defaultContainer.AddElement(subscriptionTemplatesSet);
            var defaultStoredPI = new EdmSingleton(defaultContainer, "DefaultStoredPI", storedPIType);
            defaultContainer.AddElement(defaultStoredPI);

            ((EdmEntitySet)accountSet).AddNavigationTarget(piStoredNavigation, storedPISet);
            ((EdmEntitySet)accountSet).AddNavigationTarget(accountAvailableSubsTemplatesNavigation, subscriptionTemplatesSet);
            ((EdmEntitySet)accountSet).AddNavigationTarget(piBackupStoredPINavigation, defaultStoredPI);

            #endregion

            IEnumerable<EdmError> errors = null;
            model.Validate(out errors);
            //TODO: Fix the errors

            return model;
        }
コード例 #28
0
ファイル: ModelBuilder.cs プロジェクト: larsenjo/odata.net
        public static IEdmModel ModelWithAllConceptsEdm()
        {
            var stringType = EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String);

            var model = new EdmModel();
            var addressType = new EdmComplexType("NS1", "Address");
            addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("City", new EdmStringTypeReference(stringType, /*isNullable*/false, /*isUnbounded*/false, /*maxLength*/30, /*isUnicode*/true));
            model.AddElement(addressType);

            var zipCodeType = new EdmComplexType("NS1", "ZipCode");
            zipCodeType.AddStructuralProperty("Main", new EdmStringTypeReference(stringType, /*isNullable*/false, /*isUnbounded*/false, /*maxLength*/5, /*isUnicode*/false));
            zipCodeType.AddStructuralProperty("Extended", new EdmStringTypeReference(stringType, /*isNullable*/true, /*isUnbounded*/false, /*maxLength*/5, /*isUnicode*/false));
            model.AddElement(zipCodeType);
            addressType.AddStructuralProperty("Zip", new EdmComplexTypeReference(zipCodeType, false));

            var foreignAddressType = new EdmComplexType("NS1", "ForeignAddress", addressType, false);
            foreignAddressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
            model.AddElement(foreignAddressType);

            var personType = new EdmEntityType("NS1", "Person", null, true, false);
            personType.AddKeys(personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false));
            model.AddElement(personType);

            var customerType = new EdmEntityType("NS1", "Customer", personType);
            customerType.AddStructuralProperty("IsVIP", EdmPrimitiveTypeKind.Boolean);
            customerType.AddProperty(new EdmStructuralProperty(customerType, "LastUpdated", EdmCoreModel.Instance.GetDateTimeOffset(false), null, EdmConcurrencyMode.Fixed));
            customerType.AddStructuralProperty("BillingAddress", new EdmComplexTypeReference(addressType, false));
            customerType.AddStructuralProperty("ShippingAddress", new EdmComplexTypeReference(addressType, false));
            model.AddElement(customerType);

            var orderType = new EdmEntityType("NS1", "Order");
            orderType.AddKeys(orderType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false));
            var customerIdProperty = orderType.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);
            model.AddElement(orderType);

            var navProp1 = new EdmNavigationPropertyInfo { Name = "ToOrders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many, };
            var navProp2 = new EdmNavigationPropertyInfo { Name = "ToCustomer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { customerIdProperty }, PrincipalProperties = customerType.Key() };
            customerType.AddBidirectionalNavigation(navProp1, navProp2);

            var container = new EdmEntityContainer("NS1", "MyContainer");
            container.AddEntitySet("PersonSet", personType);
            container.AddEntitySet("OrderSet", orderType);
            model.AddElement(container);

            var function = new EdmFunction("NS1", "Function1", EdmCoreModel.Instance.GetInt64(true));
            function.AddParameter("Param1", EdmCoreModel.Instance.GetInt32(true));
            container.AddFunctionImport(function);
            model.AddElement(function);

            return model;
        }
コード例 #29
0
        public void ValidateSerializationBlockingErrors()
        {
            EdmModel model = new EdmModel();

            EdmComplexType complexWithBadProperty = new EdmComplexType("Foo", "Bar");
            complexWithBadProperty.AddProperty(new EdmStructuralProperty(complexWithBadProperty, "baz", new EdmComplexTypeReference(new EdmComplexType("", ""), false)));
            model.AddElement(complexWithBadProperty);

            EdmEntityType baseType = new EdmEntityType("Foo", "");
            IEdmStructuralProperty keyProp = new EdmStructuralProperty(baseType, "Id", EdmCoreModel.Instance.GetInt32(false));
            baseType.AddProperty(keyProp);
            baseType.AddKeys(keyProp);

            EdmEntityType derivedType = new EdmEntityType("Foo", "Quip", baseType);
            model.AddElement(baseType);
            model.AddElement(derivedType);
            EdmNavigationProperty navProp = derivedType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo(){ Name="navProp", Target=derivedType, TargetMultiplicity=EdmMultiplicity.One });

            EdmEntityContainer container = new EdmEntityContainer("Foo", "Container");
            model.AddElement(container);
            container.AddElement(new EdmEntitySet(container, "badNameSet", baseType));

            StringBuilder sb = new StringBuilder();
            IEnumerable<EdmError> errors;
            bool written = model.TryWriteCsdl(XmlWriter.Create(sb), out errors);
            var expectedErrors = new EdmLibTestErrors()
            {
                { "([. Nullable=False])", EdmErrorCode.ReferencedTypeMustHaveValidName },
                { "(Foo.Quip)", EdmErrorCode.ReferencedTypeMustHaveValidName },
                { "(Microsoft.OData.Edm.Library.EdmEntitySet)", EdmErrorCode.ReferencedTypeMustHaveValidName },
            };

            this.CompareErrors(errors, expectedErrors);
        }
コード例 #30
0
        private static IEdmModel BuildModel()
        {
            EdmModel model = new EdmModel();
            
            var movieType = new EdmEntityType("TestModel", "Movie");
            EdmStructuralProperty idProperty = new EdmStructuralProperty(movieType, "Id", EdmCoreModel.Instance.GetInt32(false));
            movieType.AddProperty(idProperty);
            movieType.AddKeys(idProperty);
            movieType.AddProperty(new EdmStructuralProperty(movieType, "Name", EdmCoreModel.Instance.GetString(true)));
            model.AddElement(movieType);

            var tvMovieType = new EdmEntityType("TestModel", "TVMovie", movieType);
            tvMovieType.AddProperty(new EdmStructuralProperty(tvMovieType, "Channel", EdmCoreModel.Instance.GetString(false)));
            model.AddElement(tvMovieType);
            
            EdmEntityContainer defaultContainer = new EdmEntityContainer("TestModel", "Default");
            defaultContainer.AddEntitySet("Movies", movieType);
            model.AddElement(defaultContainer);

            EdmAction simpleAction = new EdmAction("TestModel", "SimpleAction", null /*returnType*/, false /*isBound*/, null /*entitySetPath*/);
            model.AddElement(simpleAction);
            defaultContainer.AddActionImport(simpleAction);

            EdmAction checkoutAction1 = new EdmAction("TestModel", "Checkout", EdmCoreModel.Instance.GetInt32(false), false /*isBound*/, null /*entitySetPath*/);
            checkoutAction1.AddParameter("movie", movieType.ToTypeReference());
            checkoutAction1.AddParameter("duration", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(checkoutAction1);

            EdmAction rateAction1 = new EdmAction("TestModel", "Rate", null /*returnType*/, true /*isBound*/, null /*entitySetPath*/);
            rateAction1.AddParameter("movie", movieType.ToTypeReference());
            rateAction1.AddParameter("rating", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(rateAction1);

            EdmAction changeChannelAction1 = new EdmAction("TestModel", "ChangeChannel", null /*returnType*/, true /*isBound*/, null /*entitySetPath*/);
            changeChannelAction1.AddParameter("movie", tvMovieType.ToTypeReference());
            changeChannelAction1.AddParameter("channel", EdmCoreModel.Instance.GetString(false));
            model.AddElement(changeChannelAction1);
            
            EdmAction checkoutAction = new EdmAction("TestModel", "Checkout", EdmCoreModel.Instance.GetInt32(false) /*returnType*/, false /*isBound*/, null /*entitySetPath*/);
            checkoutAction.AddParameter("movie", movieType.ToTypeReference());
            checkoutAction.AddParameter("duration", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(checkoutAction);
            
            var movieCollectionTypeReference = (new EdmCollectionType(movieType.ToTypeReference(nullable: false))).ToTypeReference(nullable:false);

            EdmAction checkoutMultiple1Action = new EdmAction("TestModel", "CheckoutMultiple", EdmCoreModel.Instance.GetInt32(false), false /*isBound*/, null /*entitySetPath*/);
            checkoutMultiple1Action.AddParameter("movies", movieCollectionTypeReference);
            checkoutMultiple1Action.AddParameter("duration", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(checkoutMultiple1Action);

            EdmAction rateMultiple1Action = new EdmAction("TestModel", "RateMultiple", null /*returnType*/, true /*isBound*/, null /*entitySetPath*/);
            rateMultiple1Action.AddParameter("movies", movieCollectionTypeReference);
            rateMultiple1Action.AddParameter("rating", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(rateMultiple1Action);

            EdmAction checkoutMultiple2Action = new EdmAction("TestModel", "CheckoutMultiple", EdmCoreModel.Instance.GetInt32(false) /*returnType*/, false /*isBound*/, null /*entitySetPath*/);
            checkoutMultiple2Action.AddParameter("movies", movieCollectionTypeReference);
            checkoutMultiple2Action.AddParameter("duration", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(checkoutMultiple2Action);

            EdmAction rateMultiple2Action = new EdmAction("TestModel", "RateMultiple", null /*returnType*/, true /*isBound*/, null /*entitySetPath*/);
            rateMultiple2Action.AddParameter("movies", movieCollectionTypeReference);
            rateMultiple2Action.AddParameter("rating", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(rateMultiple2Action);
            
            return model;
        }
コード例 #31
0
        public void ConstructibleModelODataTestModelDefaultModel()
        {
            EdmModel model = new EdmModel();

            EdmComplexType aliases = new EdmComplexType("DefaultNamespace", "Aliases");
            EdmStructuralProperty aliasesAlternativeNames = aliases.AddStructuralProperty("AlternativeNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 10, null, false)));
            model.AddElement(aliases);

            EdmComplexType phone = new EdmComplexType("DefaultNamespace", "Phone");
            EdmStructuralProperty phoneNumber = phone.AddStructuralProperty("PhoneNumber", EdmCoreModel.Instance.GetString(false, 16, null, false));
            EdmStructuralProperty phoneExtension = phone.AddStructuralProperty("Extension", EdmCoreModel.Instance.GetString(false, 16, null, true));
            model.AddElement(phone);

            EdmComplexType contact = new EdmComplexType("DefaultNamespace", "ContactDetails");
            EdmStructuralProperty contactEmailBag = contact.AddStructuralProperty("EmailBag", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 32, null, false)));
            EdmStructuralProperty contactAlternativeNames = contact.AddStructuralProperty("AlternativeNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false, 10, null, false)));
            EdmStructuralProperty contactAlias = contact.AddStructuralProperty("ContactAlias", new EdmComplexTypeReference(aliases, false));
            EdmStructuralProperty contactHomePhone = contact.AddStructuralProperty("HomePhone", new EdmComplexTypeReference(phone, false));
            EdmStructuralProperty contactWorkPhone = contact.AddStructuralProperty("WorkPhone", new EdmComplexTypeReference(phone, false));
            EdmStructuralProperty contactMobilePhoneBag = contact.AddStructuralProperty("MobilePhoneBag", EdmCoreModel.GetCollection(new EdmComplexTypeReference(phone, false)));
            model.AddElement(contact);

            EdmComplexType category = new EdmComplexType("DefaultNamespace", "ComplexToCategory");
            EdmStructuralProperty categoryTerm = category.AddStructuralProperty("Term", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty categoryScheme = category.AddStructuralProperty("Scheme", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty categoryLabel = category.AddStructuralProperty("Label", EdmCoreModel.Instance.GetString(false));
            model.AddElement(category);

            EdmComplexType dimensions = new EdmComplexType("DefaultNamespace", "Dimensions");
            EdmStructuralProperty dimensionsWidth = dimensions.AddStructuralProperty("Width", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            EdmStructuralProperty dimensionsHeight = dimensions.AddStructuralProperty("Height", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            EdmStructuralProperty dimensionsDepth = dimensions.AddStructuralProperty("Depth", EdmCoreModel.Instance.GetDecimal(10, 3, false));
            model.AddElement(dimensions);

            EdmComplexType concurrency = new EdmComplexType("DefaultNamespace", "ConcurrencyInfo");
            EdmStructuralProperty concurrencyToken = concurrency.AddStructuralProperty("Token", EdmCoreModel.Instance.GetString(false, 20, null, false));
            EdmStructuralProperty concurrencyQueriedDateTime = concurrency.AddStructuralProperty("QueriedDateTime", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(concurrency);

            EdmComplexType audit = new EdmComplexType("DefaultNamespace", "AuditInfo");
            EdmStructuralProperty auditModifiedDate = audit.AddStructuralProperty("ModifiedDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty auditModifiedBy = audit.AddStructuralProperty("ModifiedBy", EdmCoreModel.Instance.GetString(false, 50, null, false));
            EdmStructuralProperty auditConcurrency = audit.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrency, false));
            model.AddElement(audit);

            EdmEntityType customer = new EdmEntityType("DefaultNamespace", "Customer");
            EdmStructuralProperty customerId = customer.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(false));
            customer.AddKeys(customerId);
            EdmStructuralProperty customerName = customer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false));
            EdmStructuralProperty customerPrimaryContact = customer.AddStructuralProperty("PrimaryContactInfo", new EdmComplexTypeReference(contact, false));
            EdmStructuralProperty customerBackupContact = customer.AddStructuralProperty("BackupContactInfo", EdmCoreModel.GetCollection(new EdmComplexTypeReference(contact, false)));
            EdmStructuralProperty customerAuditing = customer.AddStructuralProperty("Auditing", new EdmComplexTypeReference(audit, false));
            EdmStructuralProperty customerThumbnail = customer.AddStructuralProperty("Thumbnail", EdmCoreModel.Instance.GetStream(false));
            EdmStructuralProperty customerVideo = customer.AddStructuralProperty("Video", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(customer);

            EdmEntityType barcode = new EdmEntityType("DefaultNamespace", "Barcode");
            EdmStructuralProperty barcodeCode = barcode.AddStructuralProperty("Code", EdmCoreModel.Instance.GetInt32(false));
            barcode.AddKeys(barcodeCode);
            EdmStructuralProperty barcodeProductId = barcode.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty barcodeText = barcode.AddStructuralProperty("Text", EdmCoreModel.Instance.GetString(false));
            model.AddElement(barcode);

            EdmEntityType incorrectScan = new EdmEntityType("DefaultNamespace", "IncorrectScan");
            EdmStructuralProperty incorrectScanId = incorrectScan.AddStructuralProperty("IncorrectScanId", EdmCoreModel.Instance.GetInt32(false));
            incorrectScan.AddKeys(incorrectScanId);
            EdmStructuralProperty incorrectScanExpectedCode = incorrectScan.AddStructuralProperty("ExpectedCode", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty incorrectScanActualCode = incorrectScan.AddStructuralProperty("ActualCode", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty incorrectScanDate = incorrectScan.AddStructuralProperty("ScanDate", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDateTimeOffset(false)));
            EdmStructuralProperty incorrectScanDetails = incorrectScan.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(incorrectScan);

            EdmEntityType barcodeDetail = new EdmEntityType("DefaultNamespace", "BarcodeDetail");
            EdmStructuralProperty barcodeDetailCode = barcodeDetail.AddStructuralProperty("Code", EdmCoreModel.Instance.GetInt32(false));
            barcodeDetail.AddKeys(barcodeDetailCode);
            EdmStructuralProperty barcodeDetailRegisteredTo = barcodeDetail.AddStructuralProperty("RegisteredTo", EdmCoreModel.Instance.GetString(false));
            model.AddElement(barcodeDetail);

            EdmEntityType complaint = new EdmEntityType("DefaultNamespace", "Complaint");
            EdmStructuralProperty complaintId = complaint.AddStructuralProperty("ComplaintId", EdmCoreModel.Instance.GetInt32(false));
            complaint.AddKeys(complaintId);
            EdmStructuralProperty complaintCustomerId = complaint.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty complaintLogged = complaint.AddStructuralProperty("Logged", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty complaintDetails = complaint.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(complaint);

            EdmEntityType resolution = new EdmEntityType("DefaultNamespace", "Resolution");
            EdmStructuralProperty resolutionId = resolution.AddStructuralProperty("ResolutionId", EdmCoreModel.Instance.GetInt32(false));
            resolution.AddKeys(resolutionId);
            EdmStructuralProperty resolutionDetails = resolution.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(resolution);

            EdmEntityType login = new EdmEntityType("DefaultNamespace", "Login");
            EdmStructuralProperty loginUsername = login.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            login.AddKeys(loginUsername);
            EdmStructuralProperty loginCustomerId = login.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(login);

            EdmEntityType suspiciousActivity = new EdmEntityType("DefaultNamespace", "SuspiciousActivity");
            EdmStructuralProperty suspiciousActivityId = suspiciousActivity.AddStructuralProperty("SuspiciousActivityId", EdmCoreModel.Instance.GetInt32(false));
            suspiciousActivity.AddKeys(suspiciousActivityId);
            EdmStructuralProperty suspiciousActivityProperty = suspiciousActivity.AddStructuralProperty("Activity", EdmCoreModel.Instance.GetString(false));
            model.AddElement(suspiciousActivity);

            EdmEntityType smartCard = new EdmEntityType("DefaultNamespace", "SmartCard");
            EdmStructuralProperty smartCardUsername = smartCard.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            smartCard.AddKeys(smartCardUsername);
            EdmStructuralProperty smartCardSerial = smartCard.AddStructuralProperty("CardSerial", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty smartCardIssued = smartCard.AddStructuralProperty("Issued", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(smartCard);

            EdmEntityType rsaToken = new EdmEntityType("DefaultNamespace", "RSAToken");
            EdmStructuralProperty rsaTokenSerial = rsaToken.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(false, 20, null, false));
            rsaToken.AddKeys(rsaTokenSerial);
            EdmStructuralProperty rsaTokenIssued = rsaToken.AddStructuralProperty("Issued", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(rsaToken);

            EdmEntityType passwordReset = new EdmEntityType("DefaultNamespace", "PasswordReset");
            EdmStructuralProperty passwordResetNo = passwordReset.AddStructuralProperty("ResetNo", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty passwordResetUsername = passwordReset.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            passwordReset.AddKeys(passwordResetNo);
            passwordReset.AddKeys(passwordResetUsername);
            EdmStructuralProperty passwordResetTempPassword = passwordReset.AddStructuralProperty("TempPassword", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty passwordResetEmailedTo = passwordReset.AddStructuralProperty("EmailedTo", EdmCoreModel.Instance.GetString(false));
            model.AddElement(passwordReset);

            EdmEntityType pageView = new EdmEntityType("DefaultNamespace", "PageView");
            EdmStructuralProperty pageViewId = pageView.AddStructuralProperty("PageViewId", EdmCoreModel.Instance.GetInt32(false));
            pageView.AddKeys(pageViewId);
            EdmStructuralProperty pageViewUsername = pageView.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            EdmStructuralProperty pageViewed = pageView.AddStructuralProperty("Viewed", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty pageViewPageUrl = pageView.AddStructuralProperty("PageUrl", EdmCoreModel.Instance.GetString(false, 500, null, false));
            model.AddElement(pageView);

            EdmEntityType productPageView = new EdmEntityType("DefaultNamespace", "ProductPageView", pageView);
            EdmStructuralProperty productPageViewId = productPageView.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(productPageView);

            EdmEntityType lastLogin = new EdmEntityType("DefaultNamespace", "LastLogin");
            EdmStructuralProperty lastLoginUsername = lastLogin.AddStructuralProperty("Username", EdmCoreModel.Instance.GetString(false, 50, null, false));
            lastLogin.AddKeys(lastLoginUsername);
            EdmStructuralProperty lastLoginLoggedIn = lastLogin.AddStructuralProperty("LoggedIn", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty lastLoginLoggedOut = lastLogin.AddStructuralProperty("LoggedOut", EdmCoreModel.Instance.GetDateTimeOffset(true));
            model.AddElement(lastLogin);

            EdmEntityType message = new EdmEntityType("DefaultNamespace", "Message");
            EdmStructuralProperty messageId = message.AddStructuralProperty("MessageId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty messageFromUsername = message.AddStructuralProperty("FromUsername", EdmCoreModel.Instance.GetString(false, 50, null, false));
            message.AddKeys(messageId);
            message.AddKeys(messageFromUsername);
            EdmStructuralProperty messageToUsername = message.AddStructuralProperty("ToUsername", EdmCoreModel.Instance.GetString(false, 50, null, false));
            EdmStructuralProperty messageSent = message.AddStructuralProperty("Sent", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty messageSubject = message.AddStructuralProperty("Subject", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty messageBody = message.AddStructuralProperty("Body", EdmCoreModel.Instance.GetString(true));
            EdmStructuralProperty messageIsRead = message.AddStructuralProperty("IsRead", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(message);

            EdmEntityType order = new EdmEntityType("DefaultNamespace", "Order");
            EdmStructuralProperty orderId = order.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false));
            order.AddKeys(orderId);
            EdmStructuralProperty orderCustomerId = order.AddStructuralProperty("CustomerId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty orderConcurrency = order.AddStructuralProperty("Concurrency", new EdmComplexTypeReference(concurrency, false));
            model.AddElement(order);

            EdmEntityType orderNote = new EdmEntityType("DefaultNamespace", "OrderNote");
            EdmStructuralProperty orderNoteId = orderNote.AddStructuralProperty("NoteId", EdmCoreModel.Instance.GetInt32(false));
            orderNote.AddKeys(orderNoteId);
            EdmStructuralProperty orderNoteDescription = orderNote.AddStructuralProperty("Note", EdmCoreModel.Instance.GetString(false));
            model.AddElement(orderNote);

            EdmEntityType orderQualityCheck = new EdmEntityType("DefaultNamespace", "OrderQualityCheck");
            EdmStructuralProperty orderQualityCheckId = orderQualityCheck.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false));
            orderQualityCheck.AddKeys(orderQualityCheckId);
            EdmStructuralProperty orderQualityCheckBy = orderQualityCheck.AddStructuralProperty("CheckedBy", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty orderQualityCheckDateTime = orderQualityCheck.AddStructuralProperty("CheckedDateTime", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(orderQualityCheck);

            EdmEntityType orderLine = new EdmEntityType("DefaultNamespace", "OrderLine");
            EdmStructuralProperty orderLineOrderId = orderLine.AddStructuralProperty("OrderId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty orderLineProductId = orderLine.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            orderLine.AddKeys(orderLineOrderId);
            orderLine.AddKeys(orderLineProductId);
            EdmStructuralProperty orderLineQuantity = orderLine.AddStructuralProperty("Quantity", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty orderLineConcurrencyToken = orderLine.AddStructuralProperty("ConcurrencyToken", EdmCoreModel.Instance.GetString(false), null, EdmConcurrencyMode.Fixed);
            EdmStructuralProperty orderLineStream = orderLine.AddStructuralProperty("OrderLineStream", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(orderLine);

            EdmEntityType backOrderLine = new EdmEntityType("DefaultNamespace", "BackOrderLine", orderLine);
            model.AddElement(backOrderLine);
            EdmEntityType backOrderLine2 = new EdmEntityType("DefaultNamespace", "BackOrderLine2", backOrderLine);
            model.AddElement(backOrderLine2);

            EdmEntityType product = new EdmEntityType("DefaultNamespace", "Product");
            EdmStructuralProperty productId = product.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            product.AddKeys(productId);
            EdmStructuralProperty productDescription = product.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(false, 1000, true, true));
            EdmStructuralProperty productDimensions = product.AddStructuralProperty("Dimensions", new EdmComplexTypeReference(dimensions, false));
            EdmStructuralProperty productBaseConcurrency = new EdmStructuralProperty( product, "BaseConcurrency", EdmCoreModel.Instance.GetString(false), null, EdmConcurrencyMode.Fixed);
            product.AddProperty(productBaseConcurrency);
            EdmStructuralProperty productComplexConcurrency = product.AddStructuralProperty("ComplexConcurrency", new EdmComplexTypeReference(concurrency, false));
            EdmStructuralProperty productNestedComplexConcurrency = product.AddStructuralProperty("NestedComplexConcurrency", new EdmComplexTypeReference(audit, false));
            EdmStructuralProperty productPicture = product.AddStructuralProperty("Picture", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(product);

            EdmEntityType discontinuedProduct = new EdmEntityType("DefaultNamespace", "DiscontinuedProduct", product);
            EdmStructuralProperty discontinuedProductDate = discontinuedProduct.AddStructuralProperty("Discontinued", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty discontinuedProductReplacementProductId = discontinuedProduct.AddStructuralProperty("ReplacementProductId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty discontinuedProductDiscontinuedPhone = discontinuedProduct.AddStructuralProperty("DiscontinuedPhone", new EdmComplexTypeReference(phone, false));
            model.AddElement(discontinuedProduct);

            EdmEntityType productDetail = new EdmEntityType("DefaultNamespace", "ProductDetail");
            EdmStructuralProperty productDetailProductId = productDetail.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            productDetail.AddKeys(productDetailProductId);
            EdmStructuralProperty productDetails = productDetail.AddStructuralProperty("Details", EdmCoreModel.Instance.GetString(false));
            model.AddElement(productDetail);

            EdmEntityType productReview = new EdmEntityType("DefaultNamespace", "ProductReview");
            EdmStructuralProperty productReviewProductId = productReview.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty productReviewId = productReview.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(false));
            productReview.AddKeys(productReviewProductId);
            productReview.AddKeys(productReviewId);
            EdmStructuralProperty productReviewDescription = productReview.AddStructuralProperty("Review", EdmCoreModel.Instance.GetString(false));
            model.AddElement(productReview);

            EdmEntityType productPhoto = new EdmEntityType("DefaultNamespace", "ProductPhoto");
            EdmStructuralProperty productPhotoProductId = productPhoto.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty productPhotoId = productPhoto.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(false));
            productPhoto.AddKeys(productPhotoProductId);
            productPhoto.AddKeys(productPhotoId);
            EdmStructuralProperty productPhotoBinary = productPhoto.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetBinary(false));
            model.AddElement(productPhoto);

            EdmEntityType productWebFeature = new EdmEntityType("DefaultNamespace", "ProductWebFeature");
            EdmStructuralProperty productWebFeatureId = productWebFeature.AddStructuralProperty("FeatureId", EdmCoreModel.Instance.GetInt32(false));
            productWebFeature.AddKeys(productWebFeatureId);
            EdmStructuralProperty productWebFeatureProductId = productWebFeature.AddStructuralProperty("ProductId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty productWebFeaturePhotoId = productWebFeature.AddStructuralProperty("PhotoId", EdmCoreModel.Instance.GetInt32(true));
            EdmStructuralProperty productWebFeatureReviewId = productWebFeature.AddStructuralProperty("ReviewId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty productWebFeatureHeading = productWebFeature.AddStructuralProperty("Heading", EdmCoreModel.Instance.GetString(false));
            model.AddElement(productWebFeature);

            EdmEntityType supplier = new EdmEntityType("DefaultNamespace", "Supplier");
            EdmStructuralProperty supplierId = supplier.AddStructuralProperty("SupplierId", EdmCoreModel.Instance.GetInt32(false));
            supplier.AddKeys(supplierId);
            EdmStructuralProperty supplierName = supplier.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(supplier);

            EdmEntityType supplierLogo = new EdmEntityType("DefaultNamespace", "SupplierLogo");
            EdmStructuralProperty supplierLogoSupplierId = supplierLogo.AddStructuralProperty("SupplierId", EdmCoreModel.Instance.GetInt32(false));
            supplierLogo.AddKeys(supplierLogoSupplierId);
            EdmStructuralProperty supplierLogoBinary = supplierLogo.AddStructuralProperty("Logo", EdmCoreModel.Instance.GetBinary(false, 500, false));
            model.AddElement(supplierLogo);

            EdmEntityType supplierInfo = new EdmEntityType("DefaultNamespace", "SupplierInfo");
            EdmStructuralProperty supplierInfoId = supplierInfo.AddStructuralProperty("SupplierInfoId", EdmCoreModel.Instance.GetInt32(false));
            supplierInfo.AddKeys(supplierInfoId);
            EdmStructuralProperty supplierInfoDescription = supplierInfo.AddStructuralProperty("Information", EdmCoreModel.Instance.GetString(false));
            model.AddElement(supplierInfo);

            EdmEntityType customerInfo = new EdmEntityType("DefaultNamespace", "CustomerInfo");
            EdmStructuralProperty customerInfoId = customerInfo.AddStructuralProperty("CustomerInfoId", EdmCoreModel.Instance.GetInt32(false));
            customerInfo.AddKeys(customerInfoId);
            EdmStructuralProperty customerInfoDescription = customerInfo.AddStructuralProperty("Information", EdmCoreModel.Instance.GetString(true));
            model.AddElement(customerInfo);

            EdmEntityType computer = new EdmEntityType("DefaultNamespace", "Computer");
            EdmStructuralProperty computerId = computer.AddStructuralProperty("ComputerId", EdmCoreModel.Instance.GetInt32(false));
            computer.AddKeys(computerId);
            EdmStructuralProperty computerName = computer.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(computer);

            EdmEntityType computerDetail = new EdmEntityType("DefaultNamespace", "ComputerDetail");
            EdmStructuralProperty computerDetailId = computerDetail.AddStructuralProperty("ComputerDetailId", EdmCoreModel.Instance.GetInt32(false));
            computerDetail.AddKeys(computerDetailId);
            EdmStructuralProperty computerDetailManufacturer = computerDetail.AddStructuralProperty("Manufacturer", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty computerDetailModel = computerDetail.AddStructuralProperty("Model", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty computerDetailSerial = computerDetail.AddStructuralProperty("Serial", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty computerDetailSpecificationsBag = computerDetail.AddStructuralProperty("SpecificationsBag", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false)));
            EdmStructuralProperty computerDetailPurchaseDate = computerDetail.AddStructuralProperty("PurchaseDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            EdmStructuralProperty computerDetailDimensions = computerDetail.AddStructuralProperty("Dimensions", new EdmComplexTypeReference(dimensions, false));
            model.AddElement(computerDetail);

            EdmEntityType driver = new EdmEntityType("DefaultNamespace", "Driver");
            EdmStructuralProperty driverName = driver.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false));
            driver.AddKeys(driverName);
            EdmStructuralProperty driverBirthDate = driver.AddStructuralProperty("BirthDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(driver);

            EdmEntityType license = new EdmEntityType("DefaultNamespace", "License");
            EdmStructuralProperty licenseName = license.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false, 100, null, false));
            license.AddKeys(licenseName);
            EdmStructuralProperty licenseNumber = license.AddStructuralProperty("LicenseNumber", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty licenseClass = license.AddStructuralProperty("LicenseClass", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty licenseRestrictions = license.AddStructuralProperty("Restrictions", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty licenseExpiration = license.AddStructuralProperty("ExpirationDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            model.AddElement(license);

            EdmEntityType mappedEntity = new EdmEntityType("DefaultNamespace", "MappedEntityType");
            EdmStructuralProperty mappedEntityId = mappedEntity.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            mappedEntity.AddKeys(mappedEntityId);
            EdmStructuralProperty mappedEntityHref = mappedEntity.AddStructuralProperty("Href", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityTitle = mappedEntity.AddStructuralProperty("Title", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityHrefLang = mappedEntity.AddStructuralProperty("HrefLang", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityType = mappedEntity.AddStructuralProperty("Type", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty mappedEntityLength = mappedEntity.AddStructuralProperty("Length", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty mappedEntityBagOfPrimitiveToLinks = mappedEntity.AddStructuralProperty("BagOfPrimitiveToLinks", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(false)));
            EdmStructuralProperty mappedEntityBagOfDecimals = mappedEntity.AddStructuralProperty("BagOfDecimals", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDecimal(false)));
            EdmStructuralProperty mappedEntityBagOfDoubles = mappedEntity.AddStructuralProperty("BagOfDoubles", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetDouble(false)));
            EdmStructuralProperty mappedEntityBagOfSingles = mappedEntity.AddStructuralProperty("BagOfSingles", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetSingle(false)));
            EdmStructuralProperty mappedEntityBagOfBytes = mappedEntity.AddStructuralProperty("BagOfBytes", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetByte(false)));
            EdmStructuralProperty mappedEntityBagOfInt16s = mappedEntity.AddStructuralProperty("BagOfInt16s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt16(false)));
            EdmStructuralProperty mappedEntityBagOfInt32s = mappedEntity.AddStructuralProperty("BagOfInt32s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt32(false)));
            EdmStructuralProperty mappedEntityBagOfInt64s = mappedEntity.AddStructuralProperty("BagOfInt64s", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetInt64(false)));
            EdmStructuralProperty mappedEntityBagOfGuids = mappedEntity.AddStructuralProperty("BagOfGuids", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetGuid(false)));
            EdmStructuralProperty mappedEntityBagOfComplexToCategories = mappedEntity.AddStructuralProperty("BagOfComplexToCategories", EdmCoreModel.GetCollection(new EdmComplexTypeReference(category, false)));
            model.AddElement(mappedEntity);

            EdmEntityType car = new EdmEntityType("DefaultNamespace", "Car");
            EdmStructuralProperty carVin = car.AddStructuralProperty("VIN", EdmCoreModel.Instance.GetInt32(false));
            car.AddKeys(carVin);
            EdmStructuralProperty carDescription = car.AddStructuralProperty("Description", EdmCoreModel.Instance.GetString(false, 100, null, true));
            EdmStructuralProperty carPhoto = car.AddStructuralProperty("Photo", EdmCoreModel.Instance.GetStream(false));
            EdmStructuralProperty carVideo = car.AddStructuralProperty("Video", EdmCoreModel.Instance.GetStream(false));
            model.AddElement(car);

            EdmEntityType person = new EdmEntityType("DefaultNamespace", "Person");
            EdmStructuralProperty personId = person.AddStructuralProperty("PersonId", EdmCoreModel.Instance.GetInt32(false));
            person.AddKeys(personId);
            EdmStructuralProperty personName = person.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(person);

            EdmEntityType employee = new EdmEntityType("DefaultNamespace", "Employee", person);
            EdmStructuralProperty employeeManagerId = employee.AddStructuralProperty("ManagersPersonId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty employeeSalary = employee.AddStructuralProperty("Salary", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty employeeTitle = employee.AddStructuralProperty("Title", EdmCoreModel.Instance.GetString(false));
            model.AddElement(employee);

            EdmEntityType specialEmployee = new EdmEntityType("DefaultNamespace", "SpecialEmployee", employee);
            EdmStructuralProperty specialEmployeeCarsVIN = specialEmployee.AddStructuralProperty("CarsVIN", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty specialEmployeeBonus = specialEmployee.AddStructuralProperty("Bonus", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty specialEmployeeIsFullyVested = specialEmployee.AddStructuralProperty("IsFullyVested", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(specialEmployee);

            EdmEntityType personMetadata = new EdmEntityType("DefaultNamespace", "PersonMetadata");
            EdmStructuralProperty personMetadataId = personMetadata.AddStructuralProperty("PersonMetadataId", EdmCoreModel.Instance.GetInt32(false));
            personMetadata.AddKeys(personMetadataId);
            EdmStructuralProperty personMetadataPersonId = personMetadata.AddStructuralProperty("PersonId", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty personMetadataPropertyName = personMetadata.AddStructuralProperty("PropertyName", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty personMetadataPropertyValue = personMetadata.AddStructuralProperty("PropertyValue", EdmCoreModel.Instance.GetString(false));
            model.AddElement(personMetadata);

            EdmNavigationProperty customerToOrders = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { orderCustomerId }, PrincipalProperties = customer.Key() });

            EdmNavigationProperty customerToLogins = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Logins", Target = login, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new [] { loginCustomerId }, PrincipalProperties = customer.Key()});

            EdmNavigationProperty customerToHusband = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Husband", Target = customer, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Wife", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty customerToInfo = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Info", Target = customerInfo, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty customerToComplaint = customer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Complaints", Target = complaint, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Customer", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { complaintCustomerId }, PrincipalProperties = customer.Key() });

            EdmNavigationProperty barcodeToProduct = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Product", Target = product, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barcodeProductId }, PrincipalProperties = product.Key() },
                new EdmNavigationPropertyInfo() { Name = "Barcodes", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty barcodeToExpectedIncorrectScans = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "BadScans", Target = incorrectScan, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "ExpectedBarcode", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { incorrectScanExpectedCode }, PrincipalProperties = barcode.Key() });

            EdmNavigationProperty barcodeToActualIncorrectScans = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "GoodScans", Target = incorrectScan, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "ActualBarcode", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { incorrectScanActualCode }, PrincipalProperties = barcode.Key()});

            EdmNavigationProperty barcodeToBarcodeDetail = barcode.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Detail", Target = barcodeDetail, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Barcode", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { barcodeDetailCode }, PrincipalProperties = barcode.Key()});

            EdmNavigationProperty complaintToResolution = complaint.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Resolution", Target = resolution, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Complaint", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty loginToLastLogin = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "LastLogin", Target = lastLogin, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { lastLoginUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToSentMessages = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "SentMessages", Target = message, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Sender", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { messageFromUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToReceivedMessages = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "ReceivedMessages", Target = message, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Recipient", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { messageToUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToOrders = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Orders", Target = order, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty loginToSmartCard = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "SmartCard", Target = smartCard, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { smartCardUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToRsaToken = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "RSAToken", Target = rsaToken, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty loginToPasswordReset = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "PasswordResets", Target = passwordReset, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { passwordResetUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToPageView = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "PageViews", Target = pageView, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { pageViewUsername }, PrincipalProperties = login.Key()});

            EdmNavigationProperty loginToSuspiciousActivity = login.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "SuspiciousActivity", Target = suspiciousActivity, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Login", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty smartCardToLastLogin = smartCard.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "LastLogin", Target = lastLogin, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "SmartCard", TargetMultiplicity = EdmMultiplicity.ZeroOrOne });

            EdmNavigationProperty orderToOrderLines = order.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "OrderLines", Target = orderLine, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Order", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineOrderId }, PrincipalProperties = order.Key()});

            EdmNavigationProperty orderToOrderNotes = EdmNavigationProperty.CreateNavigationPropertyWithPartner(
                new EdmNavigationPropertyInfo() { Name = "Notes", Target = orderNote, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade },
                new EdmNavigationPropertyInfo() { Name = "Order", Target = order, TargetMultiplicity = EdmMultiplicity.One });
            order.AddProperty(orderToOrderNotes);
            orderNote.AddProperty(orderToOrderNotes.Partner);

            EdmNavigationProperty orderToOrderQualityCheck = order.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "OrderQualityCheck", Target = orderQualityCheck, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Order", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderQualityCheckId }, PrincipalProperties = order.Key()});

            EdmNavigationProperty orderLineToProduct = orderLine.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Product", Target = product, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { orderLineProductId }, PrincipalProperties = product.Key()},
                new EdmNavigationPropertyInfo() { Name = "OrderLines", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty productToRelatedProducts = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "RelatedProducts", Target = product, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "ProductToRelatedProducts", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty productToSuppliers = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Suppliers", Target = supplier, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Products", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty productToProductDetail = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Detail", Target = productDetail, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productDetailProductId }, PrincipalProperties = product.Key()});

            EdmNavigationProperty productToProductReviews = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Reviews", Target = productReview, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productReviewProductId }, PrincipalProperties = product.Key()});

            EdmNavigationProperty productToProductPhotos = product.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Photos", Target = productPhoto, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Product", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { productPhotoProductId }, PrincipalProperties = product.Key()});

            EdmNavigationProperty productReviewToProductWebFeatures = productReview.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Features", Target = productWebFeature, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Review", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeatureReviewId, productWebFeatureProductId }, PrincipalProperties = productReview.Key()});

            EdmNavigationProperty productPhotoToProductWebFeatures = productPhoto.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Features", Target = productWebFeature, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Photo", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, DependentProperties = new[] { productWebFeaturePhotoId, productWebFeatureProductId }, PrincipalProperties = productPhoto.Key()});

            EdmNavigationProperty supplierToSupplierLogo = supplier.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Logo", Target = supplierLogo, TargetMultiplicity = EdmMultiplicity.ZeroOrOne },
                new EdmNavigationPropertyInfo() { Name = "Supplier", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { supplierLogoSupplierId }, PrincipalProperties = supplier.Key()});

            EdmNavigationProperty supplierToSupplierInfo = EdmNavigationProperty.CreateNavigationPropertyWithPartner(
                new EdmNavigationPropertyInfo() { Name = "SupplierInfo", Target = supplierInfo, TargetMultiplicity = EdmMultiplicity.Many, OnDelete = EdmOnDeleteAction.Cascade },
                new EdmNavigationPropertyInfo() { Name = "Supplier", Target = supplier, TargetMultiplicity = EdmMultiplicity.One });
            supplier.AddProperty(supplierToSupplierInfo);
            supplierInfo.AddProperty(supplierToSupplierInfo.Partner);

            EdmNavigationProperty computerToComputerDetail = computer.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "ComputerDetail", Target = computerDetail, TargetMultiplicity = EdmMultiplicity.One },
                new EdmNavigationPropertyInfo() { Name = "Computer", TargetMultiplicity = EdmMultiplicity.One });

            EdmNavigationProperty driverTolicense = driver.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "License", Target = license, TargetMultiplicity = EdmMultiplicity.One },
                new EdmNavigationPropertyInfo() { Name = "Driver", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { licenseName }, PrincipalProperties = driver.Key()});

            EdmNavigationProperty personToPersonMetadata = person.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "PersonMetadata", Target = personMetadata, TargetMultiplicity = EdmMultiplicity.Many },
                new EdmNavigationPropertyInfo() { Name = "Person", TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { personMetadataPersonId }, PrincipalProperties = person.Key()});

            EdmNavigationProperty employeeToManager = employee.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Manager", Target = employee, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { employeeManagerId }, PrincipalProperties = employee.Key()},
                new EdmNavigationPropertyInfo() { Name = "EmployeeToManager", TargetMultiplicity = EdmMultiplicity.Many });

            EdmNavigationProperty specialEmployeeToCar = specialEmployee.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo() { Name = "Car", Target = car, TargetMultiplicity = EdmMultiplicity.One, DependentProperties = new[] { specialEmployeeCarsVIN }, PrincipalProperties = car.Key()},
                new EdmNavigationPropertyInfo() { Name = "SpecialEmployee", TargetMultiplicity = EdmMultiplicity.Many });

            EdmOperation getPrimitiveString = new EdmFunction("DefaultNamespace", "GetPrimitiveString", EdmCoreModel.Instance.GetString(true));
            model.AddElement(getPrimitiveString);
            EdmOperation getSpecificCustomer = new EdmFunction("DefaultNamespace", "GetSpecificCustomer", EdmCoreModel.GetCollection(new EdmEntityTypeReference(customer, true)));
            getSpecificCustomer.AddParameter("Name", EdmCoreModel.Instance.GetString(false));
            model.AddElement(getSpecificCustomer);
            EdmOperation getCustomerCount = new EdmFunction("DefaultNamespace", "GetCustomerCount", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(getCustomerCount);
            EdmOperation getArgumentPlusOne = new EdmFunction("DefaultNamespace", "GetArgumentPlusOne", EdmCoreModel.Instance.GetInt32(true));
            getArgumentPlusOne.AddParameter("arg1", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(getArgumentPlusOne);
            EdmOperation entityProjectionReturnsCollectionOfComplexTypes = new EdmFunction("DefaultNamespace", "EntityProjectionReturnsCollectionOfComplexTypes", EdmCoreModel.GetCollection(new EdmComplexTypeReference(contact, true)));
            model.AddElement(entityProjectionReturnsCollectionOfComplexTypes);

            EdmOperation setArgumentPlusOne = new EdmAction("DefaultNamespace", "SetArgumentPlusOne", EdmCoreModel.Instance.GetInt32(true));
            setArgumentPlusOne.AddParameter("arg1", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(setArgumentPlusOne);

            EdmEntityContainer container = new EdmEntityContainer("DefaultNamespace", "DefaultContainer");
            model.AddElement(container);

            EdmEntitySet carSet = container.AddEntitySet("Car", car);
            EdmEntitySet customerSet = container.AddEntitySet("Customer", customer);
            EdmEntitySet barcodeSet = container.AddEntitySet("Barcode", barcode);
            EdmEntitySet incorrectScanSet = container.AddEntitySet("IncorrectScan", incorrectScan);
            EdmEntitySet barcodeDetailSet = container.AddEntitySet("BarcodeDetail", barcodeDetail);
            EdmEntitySet complaintSet = container.AddEntitySet("Complaint", complaint);
            EdmEntitySet resolutionSet = container.AddEntitySet("Resolution", resolution);
            EdmEntitySet loginSet = container.AddEntitySet("Login", login);
            EdmEntitySet suspiciousActivitySet = container.AddEntitySet("SuspiciousActivity", suspiciousActivity);
            EdmEntitySet smartCardSet = container.AddEntitySet("SmartCard", smartCard);
            EdmEntitySet rsaTokenSet = container.AddEntitySet("RSAToken", rsaToken);
            EdmEntitySet passwordResetSet = container.AddEntitySet("PasswordReset", passwordReset);
            EdmEntitySet pageViewSet = container.AddEntitySet("PageView", pageView);
            EdmEntitySet lastLoginSet = container.AddEntitySet("LastLogin", lastLogin);
            EdmEntitySet messageSet = container.AddEntitySet("Message", message);
            EdmEntitySet orderSet = container.AddEntitySet("Order", order);
            EdmEntitySet orderNoteSet = container.AddEntitySet("OrderNote", orderNote);
            EdmEntitySet orderQualityCheckSet = container.AddEntitySet("OrderQualityCheck", orderQualityCheck);
            EdmEntitySet orderLineSet = container.AddEntitySet("OrderLine", orderLine);
            EdmEntitySet productSet = container.AddEntitySet("Product", product);
            EdmEntitySet productDetailSet = container.AddEntitySet("ProductDetail", productDetail);
            EdmEntitySet productReviewSet = container.AddEntitySet("ProductReview", productReview);
            EdmEntitySet productPhotoSet = container.AddEntitySet("ProductPhoto", productPhoto);
            EdmEntitySet productWebFeatureSet = container.AddEntitySet("ProductWebFeature", productWebFeature);
            EdmEntitySet supplierSet = container.AddEntitySet("Supplier", supplier);
            EdmEntitySet supplierLogoSet = container.AddEntitySet("SupplierLogo", supplierLogo);
            EdmEntitySet supplierInfoSet = container.AddEntitySet("SupplierInfo", supplierInfo);
            EdmEntitySet customerInfoSet = container.AddEntitySet("CustomerInfo", customerInfo);
            EdmEntitySet computerSet = container.AddEntitySet("Computer", computer);
            EdmEntitySet computerDetailSet = container.AddEntitySet("ComputerDetail", computerDetail);
            EdmEntitySet driverSet = container.AddEntitySet("Driver", driver);
            EdmEntitySet licenseSet = container.AddEntitySet("License", license);
            EdmEntitySet mappedEntitySet = container.AddEntitySet("MappedEntityType", mappedEntity);
            EdmEntitySet personSet = container.AddEntitySet("Person", person);
            EdmEntitySet personMetadataSet = container.AddEntitySet("PersonMetadata", personMetadata);

            complaintSet.AddNavigationTarget(customerToComplaint.Partner, customerSet);
            loginSet.AddNavigationTarget(loginToSentMessages, messageSet);
            loginSet.AddNavigationTarget(loginToReceivedMessages, messageSet);
            customerInfoSet.AddNavigationTarget(customerToInfo.Partner, customerSet);
            supplierSet.AddNavigationTarget(supplierToSupplierInfo, supplierInfoSet);
            loginSet.AddNavigationTarget(loginToOrders, orderSet);
            orderSet.AddNavigationTarget(orderToOrderNotes, orderNoteSet);
            orderSet.AddNavigationTarget(orderToOrderQualityCheck, orderQualityCheckSet);
            supplierSet.AddNavigationTarget(supplierToSupplierLogo, supplierLogoSet);
            customerSet.AddNavigationTarget(customerToOrders, orderSet);
            customerSet.AddNavigationTarget(customerToLogins, loginSet);
            loginSet.AddNavigationTarget(loginToLastLogin, lastLoginSet);
            lastLoginSet.AddNavigationTarget(smartCardToLastLogin.Partner, smartCardSet);
            orderSet.AddNavigationTarget(orderToOrderLines, orderLineSet);
            productSet.AddNavigationTarget(orderLineToProduct.Partner, orderLineSet);
            productSet.AddNavigationTarget(productToRelatedProducts, productSet);
            productSet.AddNavigationTarget(productToProductDetail, productDetailSet);
            productSet.AddNavigationTarget(productToProductReviews, productReviewSet);
            productSet.AddNavigationTarget(productToProductPhotos, productPhotoSet);
            productWebFeatureSet.AddNavigationTarget(productPhotoToProductWebFeatures.Partner, productPhotoSet);
            productWebFeatureSet.AddNavigationTarget(productReviewToProductWebFeatures.Partner, productReviewSet);
            complaintSet.AddNavigationTarget(complaintToResolution, resolutionSet);
            barcodeSet.AddNavigationTarget(barcodeToExpectedIncorrectScans, incorrectScanSet);
            customerSet.AddNavigationTarget(customerToHusband.Partner, customerSet);
            barcodeSet.AddNavigationTarget(barcodeToActualIncorrectScans, incorrectScanSet);
            productSet.AddNavigationTarget(barcodeToProduct.Partner, barcodeSet);
            barcodeSet.AddNavigationTarget(barcodeToBarcodeDetail, barcodeDetailSet);
            loginSet.AddNavigationTarget(loginToSuspiciousActivity, suspiciousActivitySet);
            loginSet.AddNavigationTarget(loginToRsaToken, rsaTokenSet);
            loginSet.AddNavigationTarget(loginToSmartCard, smartCardSet);
            loginSet.AddNavigationTarget(loginToPasswordReset, passwordResetSet);
            loginSet.AddNavigationTarget(loginToPageView, pageViewSet);
            computerSet.AddNavigationTarget(computerToComputerDetail, computerDetailSet);
            driverSet.AddNavigationTarget(driverTolicense, licenseSet);
            personSet.AddNavigationTarget(personToPersonMetadata, personMetadataSet);
            productSet.AddNavigationTarget(productToSuppliers, supplierSet);
            carSet.AddNavigationTarget(specialEmployeeToCar.Partner, personSet);
            personSet.AddNavigationTarget(employeeToManager, personSet);

            this.BasicConstructibleModelTestSerializingStockModel(ODataTestModelBuilder.ODataTestModelDefaultModel, model);
        }