Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
        public void EnsureActionImportIsAddedAndWithCorrectSuppliedName()
        {
            EdmEntityContainer container = new EdmEntityContainer("Default", "Container");
            EdmAction action = new EdmAction("DS", "TestAction", EdmCoreModel.Instance.GetBoolean(false));
            var actionImport = container.AddActionImport("OtherName", action);

            actionImport.Action.Should().Be(action);
            actionImport.Name.Should().Be("OtherName");
            container.Elements.ToArray()[0].Should().Be(actionImport);
        }
Exemplo n.º 3
0
        public void EnsureActionImportIsAddedAndWithCorrectEntitySetExpression()
        {
            EdmEntityContainer container = new EdmEntityContainer("Default", "Container");
            EdmAction action = new EdmAction("DS", "TestAction", EdmCoreModel.Instance.GetBoolean(false));
            var edmEntitySet = new EdmEntitySet(container, "EntitySet", new EdmEntityType("DS", "TestEntity"));
            var entitySetExpression = new EdmEntitySetReferenceExpression(edmEntitySet);
            var actionImport = container.AddActionImport("OtherName", action, entitySetExpression);

            actionImport.Action.Should().Be(action);
            actionImport.Name.Should().Be("OtherName");
            actionImport.EntitySet.Should().Be(entitySetExpression);
            container.Elements.ToArray()[0].Should().Be(actionImport);
        }
        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;
        }
        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();
        }
        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;
        }
        public void ConstructibleModelODataTestModelAnnotationTestWithoutAnnotation()
        {
            EdmModel model = new EdmModel();

            EdmComplexType address = new EdmComplexType("TestModel", "Address");
            EdmStructuralProperty addressStreet = address.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(true));
            EdmStructuralProperty addressZip = address.AddStructuralProperty("Zip", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(address);

            EdmEntityType person = new EdmEntityType("TestModel", "PersonType");
            EdmStructuralProperty personID = person.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            EdmStructuralProperty personName = person.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty personAddress = person.AddStructuralProperty("Address", new EdmComplexTypeReference(address, false));
            EdmStructuralProperty personPicture = person.AddStructuralProperty("Picture", EdmCoreModel.Instance.GetStream(false));
            person.AddKeys(personID);
            model.AddElement(person);

            EdmEntityContainer container = new EdmEntityContainer("TestModel", "DefaultContainer");
            EdmEntitySet peopleSet = container.AddEntitySet("People", person);
            EdmEntitySet personSet = container.AddEntitySet("PersonType", person);

            EdmAction serviceOperationAction = new EdmAction("TestModel", "ServiceOperation1", EdmCoreModel.Instance.GetInt32(false));
            EdmOperationParameter a = new EdmOperationParameter(serviceOperationAction, "a", EdmCoreModel.Instance.GetInt32(true));
            EdmOperationParameter b = new EdmOperationParameter(serviceOperationAction, "b", EdmCoreModel.Instance.GetString(true));
            serviceOperationAction.AddParameter(a);
            serviceOperationAction.AddParameter(b);
            model.AddElement(serviceOperationAction);
            container.AddActionImport("ServiceOperation1", serviceOperationAction);
            model.AddElement(container);

            this.BasicConstructibleModelTestSerializingStockModel(ODataTestModelBuilder.ODataTestModelAnnotationTestWithoutAnnotations, model);
        }
        public void ConstructibleModelODataTestModelWithFunctionImport()
        {
            EdmModel model = new EdmModel();

            EdmComplexType complexType = new EdmComplexType("TestModel", "ComplexType");
            EdmStructuralProperty primitiveProperty = complexType.AddStructuralProperty("PrimitiveProperty", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty complexProperty = complexType.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType, false));
            model.AddElement(complexType);

            EdmEntityType entity = new EdmEntityType("TestNS", "EntityType");
            EdmStructuralProperty entityId = entity.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            entity.AddKeys(entityId);
            EdmStructuralProperty entityComplexProperty = entity.AddStructuralProperty("ComplexProperty", new EdmComplexTypeReference(complexType, false));
            model.AddElement(entity);

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

            EdmEntityContainer container = new EdmEntityContainer("TestNS", "TestContainer");
            EdmAction primitiveOperationAction = new EdmAction("TestNS", "FunctionImport_Primitive", null);
            EdmOperationParameter primitiveParameter = new EdmOperationParameter(primitiveOperationAction, "primitive", EdmCoreModel.Instance.GetString(true));
            primitiveOperationAction.AddParameter(primitiveParameter);
            model.AddElement(primitiveOperationAction);
            container.AddActionImport("FunctionImport_Primitive", primitiveOperationAction);

            EdmAction primitiveCollectionOperationAction = new EdmAction("TestNS", "FunctionImport_PrimitiveCollection", null);
            EdmOperationParameter primitiveCollectionParameter = new EdmOperationParameter(primitiveCollectionOperationAction, "primitiveCollection", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(true)));
            primitiveCollectionOperationAction.AddParameter(primitiveCollectionParameter);
            model.AddElement(primitiveCollectionOperationAction);
            container.AddActionImport("FunctionImport_PrimitiveCollection", primitiveCollectionOperationAction);

            EdmAction complexOperationAction = new EdmAction("TestNS", "FunctionImport_Complex", null);
            EdmOperationParameter complexParameter = new EdmOperationParameter(complexOperationAction, "complex", new EdmComplexTypeReference(complexType, true));
            complexOperationAction.AddParameter(complexParameter);
            model.AddElement(complexOperationAction);
            container.AddActionImport("FunctionImport_Complex", complexOperationAction);

            EdmAction complexCollectionOperationAction = new EdmAction("TestNS", "FunctionImport_ComplexCollection", null);
            EdmOperationParameter complexCollectionParameter = new EdmOperationParameter(complexCollectionOperationAction, "complexCollection", EdmCoreModel.GetCollection(new EdmComplexTypeReference(complexType, true)));
            complexCollectionOperationAction.AddParameter(complexCollectionParameter);
            model.AddElement(complexCollectionOperationAction);
            container.AddActionImport("FunctionImport_ComplexCollection", complexCollectionOperationAction);

            EdmAction entityOperationAction = new EdmAction("TestNS", "FunctionImport_Entry", null);
            EdmOperationParameter entityParameter = new EdmOperationParameter(entityOperationAction, "entry", new EdmEntityTypeReference(entity, true));
            entityOperationAction.AddParameter(entityParameter);
            model.AddElement(entityOperationAction);
            container.AddActionImport("FunctionImport_Entry", entityOperationAction);

            EdmAction feedOperationAction = new EdmAction("TestNS", "FunctionImport_Feed", null);
            EdmOperationParameter feedParameter = new EdmOperationParameter(feedOperationAction, "feed", EdmCoreModel.GetCollection(new EdmEntityTypeReference(entity, true)));
            feedOperationAction.AddParameter(feedParameter);
            model.AddElement(feedOperationAction);
            container.AddActionImport("FunctionImport_Feed", feedOperationAction);

            EdmAction streamOperationAction = new EdmAction("TestNS", "FunctionImport_Stream", null);
            EdmOperationParameter streamParameter = new EdmOperationParameter(streamOperationAction, "stream", EdmCoreModel.Instance.GetStream(true));
            streamOperationAction.AddParameter(streamParameter);
            model.AddElement(streamOperationAction);
            container.AddActionImport("FunctionImport_Stream", streamOperationAction);
            
            EdmAction enumOperationAction = new EdmAction("TestNS", "FunctionImport_Enum", null);
            EdmOperationParameter enumParameter = new EdmOperationParameter(enumOperationAction, "enum", new EdmEnumTypeReference(enumType, true));
            enumOperationAction.AddParameter(enumParameter);
            model.AddElement(enumOperationAction);
            container.AddActionImport("FunctionImport_Enum", enumOperationAction);

            model.AddElement(container);

            this.BasicConstructibleModelTestSerializingStockModel(ODataTestModelBuilder.ODataTestModelWithFunctionImport, model);
        }
        private void BuildEdmModel()
        {
            _entityType = new EdmEntityTypeReference(new EdmEntityType("NS", "Entity"), isNullable: false);
            _derivedEntityType = new EdmEntityTypeReference(new EdmEntityType("NS", "DerivedEntity", _entityType.EntityDefinition()), isNullable: false);
            var entityCollection = new EdmCollectionTypeReference(new EdmCollectionType(_entityType));
            var derivedEntityCollection = new EdmCollectionTypeReference(new EdmCollectionType(_derivedEntityType));

            EdmModel model = new EdmModel();
            EdmEntityContainer container = new EdmEntityContainer("NS", "Name");
            model.AddElement(container);

            // non-bindable action
            container.AddActionImport(new EdmAction("NS", "NonBindableAction", returnType: null));

            // action bound to entity
            var actionBoundToEntity = new EdmAction(
                "NS",
                "ActionBoundToEntity",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToEntity.AddParameter("bindingParameter", _entityType);
            model.AddElement(actionBoundToEntity);

            // action bound to derived entity
            var actionBoundToDerivedEntity = new EdmAction(
                "NS",
                "ActionBoundToDerivedEntity",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToDerivedEntity.AddParameter("bindingParameter", _derivedEntityType);
            model.AddElement(actionBoundToDerivedEntity);

            // action bound to entity collection
            var actionBoundToEntityCollection = new EdmAction(
                "NS",
                "ActionBoundToEntityCollection",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToEntityCollection.AddParameter("bindingParameter", entityCollection);
            model.AddElement(actionBoundToEntityCollection);

            // action bound to derived entity collection
            var actionBoundToDerivedEntityCollection = new EdmAction(
                "NS",
                "ActionBoundToDerivedEntityCollection",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToDerivedEntityCollection.AddParameter("bindingParameter", derivedEntityCollection);
            model.AddElement(actionBoundToDerivedEntityCollection);

            // ambiguos actions
            container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));
            container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));

            IEdmTypeReference returnType = new EdmPrimitiveTypeReference(
                EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32), false);

            // non-bindable function
            container.AddFunctionImport(new EdmFunction("NS", "NonBindableFunction", returnType));

            // function bound to entity
            var functionBoundToEntity = new EdmFunction(
                "NS",
                "FunctionBoundToEntity",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToEntity.AddParameter("bindingParameter", _entityType);
            model.AddElement(functionBoundToEntity);

            // function bound to entity
            var functionBoundToDerivedEntity = new EdmFunction(
                "NS",
                "FunctionBoundToDerivedEntity",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToDerivedEntity.AddParameter("bindingParameter", _derivedEntityType);
            model.AddElement(functionBoundToDerivedEntity);

            // function bound to entity collection
            var functionBoundToEntityCollection = new EdmFunction(
                "NS",
                "FunctionBoundToEntityCollection",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToEntityCollection.AddParameter("bindingParameter", entityCollection);
            model.AddElement(functionBoundToEntityCollection);

            // function bound to derived entity collection
            var functionBoundToDerivedEntityCollection = new EdmFunction(
                "NS",
                "FunctionBoundToDerivedEntityCollection",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToDerivedEntityCollection.AddParameter("bindingParameter", derivedEntityCollection);
            model.AddElement(functionBoundToDerivedEntityCollection);

            _model = model;
            _container = container;
        }
        public void ConstructibleModelODataTestModelBasicTest()
        {
            EdmModel model = new EdmModel();

            EdmComplexType address = new EdmComplexType("TestModel", "Address");
            model.AddElement(address);

            EdmStructuralProperty addressStreet = address.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(true));
            EdmStructuralProperty addressZip = new EdmStructuralProperty(address, "Zip", EdmCoreModel.Instance.GetInt32(false));
            address.AddProperty(addressZip);

            EdmEntityType office = new EdmEntityType("TestModel", "OfficeType");
            EdmStructuralProperty officeId = office.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            office.AddKeys(officeId);
            EdmStructuralProperty officeAddress = office.AddStructuralProperty("Address", new EdmComplexTypeReference(address, false));
            model.AddElement(office);

            EdmEntityType city = new EdmEntityType("TestModel", "CityType");
            EdmStructuralProperty cityId = city.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            city.AddKeys(cityId);
            EdmStructuralProperty cityName = city.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(true));
            EdmStructuralProperty citySkyline = city.AddStructuralProperty("Skyline", EdmCoreModel.Instance.GetStream(false));
            EdmStructuralProperty cityMetroLanes = city.AddStructuralProperty("MetroLanes", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(true)));
            EdmNavigationProperty cityHall = city.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "CityHall", Target = office, TargetMultiplicity = EdmMultiplicity.Many });
            EdmNavigationProperty dol = city.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "DOL", Target = office, TargetMultiplicity = EdmMultiplicity.Many });
            EdmNavigationProperty policeStation = city.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "PoliceStation", Target = office, TargetMultiplicity = EdmMultiplicity.One });
            model.AddElement(city);

            EdmEntityType cityWithMap = new EdmEntityType("TestModel", "CityWithMapType", city);
            model.AddElement(cityWithMap);

            EdmEntityType cityOpenType = new EdmEntityType("TestModel", "CityOpenType", city, false, true);
            model.AddElement(cityOpenType);

            EdmEntityType person = new EdmEntityType("TestModel", "Person");
            EdmStructuralProperty personId = person.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(false));
            person.AddKeys(personId);
            model.AddElement(person);

            EdmNavigationProperty friend = person.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Friend", Target = person, TargetMultiplicity = EdmMultiplicity.Many });

            EdmEntityType employee = new EdmEntityType("TestModel", "Employee", person);
            EdmStructuralProperty companyName = employee.AddStructuralProperty("CompanyName", EdmCoreModel.Instance.GetString(true));
            model.AddElement(employee);

            EdmEntityType manager = new EdmEntityType("TestModel", "Manager", employee);
            EdmStructuralProperty level = manager.AddStructuralProperty("Level", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(manager);

            EdmEntityContainer container = new EdmEntityContainer("TestModel", "DefaultContainer");
            EdmEntitySet officeSet = new EdmEntitySet(container, "OfficeType", office);
            container.AddElement(officeSet);
            EdmEntitySet citySet = container.AddEntitySet("CityType", city);
            EdmEntitySet personSet = container.AddEntitySet("Person", person);

            citySet.AddNavigationTarget(cityHall, officeSet);
            citySet.AddNavigationTarget(dol, officeSet);
            citySet.AddNavigationTarget(policeStation, officeSet);
            personSet.AddNavigationTarget(friend, personSet);

            EdmAction serviceOperationAction = new EdmAction("TestModel", "ServiceOperation1", EdmCoreModel.Instance.GetInt32(true));
            EdmOperationParameter a = new EdmOperationParameter(serviceOperationAction, "a", EdmCoreModel.Instance.GetInt32(true));
            serviceOperationAction.AddParameter(a);
            serviceOperationAction.AddParameter("b", EdmCoreModel.Instance.GetString(true));
            model.AddElement(serviceOperationAction);
            
            container.AddActionImport("ServiceOperation1", serviceOperationAction);
            
            model.AddElement(container);

            this.BasicConstructibleModelTestSerializingStockModel(ODataTestModelBuilder.ODataTestModelBasicTest, model);
        }
Exemplo n.º 11
0
        public static EdmModel GetModelWithActionWithMissingReturnSet()
        {
            EdmEntityType vegetableType = new EdmEntityType("Test", "Vegetable");
            IEdmStructuralProperty id = vegetableType.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            vegetableType.AddKeys(id);

            EdmAction action = new EdmAction("Test", "ActionWithMissingReturnSet", new EdmEntityTypeReference(vegetableType, true));
            // Note how the entity set expression is null even though it returns an entity
            EdmEntityContainer container = new EdmEntityContainer("Test", "Container");
            container.AddActionImport("ActionWithMissingReturnSet", action);

            EdmModel model = new EdmModel();
            model.AddElement(container);
            model.AddElement(vegetableType);
            model.AddElement(action);
            return model;
        }
Exemplo n.º 12
0
        internal static IEdmModel GetEdmModel()
        {
            var model = new EdmModel();

            #region Type Definitions

            var FullyQualifiedNamespaceIdType = new EdmTypeDefinition("Fully.Qualified.Namespace", "IdType", EdmPrimitiveTypeKind.Double);
            var FullyQualifiedNamespaceIdTypeReference = new EdmTypeDefinitionReference(FullyQualifiedNamespaceIdType, false);
            model.AddElement(FullyQualifiedNamespaceIdType);

            var FullyQualifiedNamespaceNameType = new EdmTypeDefinition("Fully.Qualified.Namespace", "NameType", EdmPrimitiveTypeKind.String);
            var FullyQualifiedNamespaceNameTypeReference = new EdmTypeDefinitionReference(FullyQualifiedNamespaceNameType, false);
            model.AddElement(FullyQualifiedNamespaceNameType);

            var FullyQualifiedNamespaceUInt16Reference = model.GetUInt16("Fully.Qualified.Namespace", false);
            var FullyQualifiedNamespaceUInt32Reference = model.GetUInt32("Fully.Qualified.Namespace", false);
            var FullyQualifiedNamespaceUInt64Reference = model.GetUInt64("Fully.Qualified.Namespace", false);

            #endregion

            #region Enum Types
            var colorType = new EdmEnumType("Fully.Qualified.Namespace", "ColorPattern", EdmPrimitiveTypeKind.Int64, true);
            colorType.AddMember("Red", new EdmIntegerConstant(1L));
            colorType.AddMember("Blue", new EdmIntegerConstant(2L));
            colorType.AddMember("Yellow", new EdmIntegerConstant(4L));
            colorType.AddMember("Solid", new EdmIntegerConstant(8L));
            colorType.AddMember("Striped", new EdmIntegerConstant(16L));
            colorType.AddMember("SolidRed", new EdmIntegerConstant(9L));
            colorType.AddMember("SolidBlue", new EdmIntegerConstant(10L));
            colorType.AddMember("SolidYellow", new EdmIntegerConstant(12L));
            colorType.AddMember("RedBlueStriped", new EdmIntegerConstant(19L));
            colorType.AddMember("RedYellowStriped", new EdmIntegerConstant(21L));
            colorType.AddMember("BlueYellowStriped", new EdmIntegerConstant(22L));
            model.AddElement(colorType);
            var colorTypeReference = new EdmEnumTypeReference(colorType, false);
            var nullableColorTypeReference = new EdmEnumTypeReference(colorType, true);

            var NonFlagShapeType = new EdmEnumType("Fully.Qualified.Namespace", "NonFlagShape", EdmPrimitiveTypeKind.SByte, false);
            NonFlagShapeType.AddMember("Rectangle", new EdmIntegerConstant(1));
            NonFlagShapeType.AddMember("Triangle", new EdmIntegerConstant(2));
            NonFlagShapeType.AddMember("foursquare", new EdmIntegerConstant(3));
            model.AddElement(NonFlagShapeType);
            #endregion

            #region Structured Types
            var FullyQualifiedNamespacePerson = new EdmEntityType("Fully.Qualified.Namespace", "Person", null, false, false);
            var FullyQualifiedNamespaceEmployee = new EdmEntityType("Fully.Qualified.Namespace", "Employee", FullyQualifiedNamespacePerson, false, false);
            var FullyQualifiedNamespaceManager = new EdmEntityType("Fully.Qualified.Namespace", "Manager", FullyQualifiedNamespaceEmployee, false, false);
            var FullyQualifiedNamespaceOpenEmployee = new EdmEntityType("Fully.Qualified.Namespace", "OpenEmployee", FullyQualifiedNamespaceEmployee, false, true);
            var FullyQualifiedNamespaceDog = new EdmEntityType("Fully.Qualified.Namespace", "Dog", null, false, false);
            var FullyQualifiedNamespaceLion = new EdmEntityType("Fully.Qualified.Namespace", "Lion", null, false, false);
            var FullyQualifiedNamespaceChimera = new EdmEntityType("Fully.Qualified.Namespace", "Chimera", null, false, true);
            var FullyQualifiedNamespacePainting = new EdmEntityType("Fully.Qualified.Namespace", "Painting", null, false, true);
            var FullyQualifiedNamespaceFramedPainting = new EdmEntityType("Fully.Qualified.Namespace", "FramedPainting", FullyQualifiedNamespacePainting, false, true);
            var FullyQualifiedNamespaceUserAccount = new EdmEntityType("Fully.Qualified.Namespace", "UserAccount", null, false, false);
            var FullyQualifiedNamespacePet1 = new EdmEntityType("Fully.Qualified.Namespace", "Pet1", null, false, false);
            var FullyQualifiedNamespacePet2 = new EdmEntityType("Fully.Qualified.Namespace", "Pet2", null, false, false);
            var FullyQualifiedNamespacePet3 = new EdmEntityType("Fully.Qualified.Namespace", "Pet3", null, false, false);
            var FullyQualifiedNamespacePet4 = new EdmEntityType("Fully.Qualified.Namespace", "Pet4", null, false, false);
            var FullyQualifiedNamespacePet5 = new EdmEntityType("Fully.Qualified.Namespace", "Pet5", null, false, false);
            var FullyQualifiedNamespacePet6 = new EdmEntityType("Fully.Qualified.Namespace", "Pet6", null, false, false);

            var FullyQualifiedNamespaceAddress = new EdmComplexType("Fully.Qualified.Namespace", "Address");
            var FullyQualifiedNamespaceOpenAddress = new EdmComplexType("Fully.Qualified.Namespace", "OpenAddress", null, false, true);
            var FullyQualifiedNamespaceHomeAddress = new EdmComplexType("Fully.Qualified.Namespace", "HomeAddress", FullyQualifiedNamespaceAddress);

            var FullyQualifiedNamespacePersonTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePerson, true);
            var FullyQualifiedNamespaceEmployeeTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceEmployee, true);
            var FullyQualifiedNamespaceManagerTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceManager, true);
            var FullyQualifiedNamespaceOpenEmployeeTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceOpenEmployee, true);
            var FullyQualifiedNamespaceDogTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceDog, true);
            var FullyQualifiedNamespaceLionTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceLion, true);
            var FullyQualifiedNamespacePet1TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet1, true);
            var FullyQualifiedNamespacePet2TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet2, true);
            var FullyQualifiedNamespacePet3TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet3, true);
            var FullyQualifiedNamespacePet4TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet4, true);
            var FullyQualifiedNamespacePet5TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet5, true);
            var FullyQualifiedNamespacePet6TypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePet6, true);
            var FullyQualifiedNamespacePaintingTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespacePainting, true);
            var FullyQualifiedNamespaceFramedPaintingTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceFramedPainting, true);
            var FullyQualifiedNamespaceUserAccountTypeReference = new EdmEntityTypeReference(FullyQualifiedNamespaceUserAccount, true);

            var FullyQualifiedNamespaceLion_ID1 = FullyQualifiedNamespaceLion.AddStructuralProperty("ID1", EdmCoreModel.Instance.GetInt32(false));
            var FullyQualifiedNamespaceLion_ID2 = FullyQualifiedNamespaceLion.AddStructuralProperty("ID2", EdmCoreModel.Instance.GetInt32(false));
            FullyQualifiedNamespaceLion.AddStructuralProperty("AngerLevel", EdmCoreModel.Instance.GetDouble(true));
            FullyQualifiedNamespaceLion.AddStructuralProperty("AttackDates", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDateTimeOffset(true))));
            FullyQualifiedNamespaceLion.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespaceLion_ID1, FullyQualifiedNamespaceLion_ID2, });
            model.AddElement(FullyQualifiedNamespaceLion);

            var FullyQualifiedNamespaceAddressTypeReference = new EdmComplexTypeReference(FullyQualifiedNamespaceAddress, true);
            var FullyQualifiedNamespaceOpenAddressTypeReference = new EdmComplexTypeReference(FullyQualifiedNamespaceOpenAddress, true);
            var FullyQualifiedNamespacePerson_ID = FullyQualifiedNamespacePerson.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            var FullyQualifiedNamespacePerson_SSN = FullyQualifiedNamespacePerson.AddStructuralProperty("SSN", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("Shoe", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyPoint", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyLineString", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyLineString, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyPolygon", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPolygon, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryPoint", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPoint, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryLineString", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryLineString, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryPolygon", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPolygon, true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeographyCollection", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true))));
            FullyQualifiedNamespacePerson.AddStructuralProperty("GeometryCollection", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPoint, true))));
            var FullyQualifiedNamespacePerson_Name = FullyQualifiedNamespacePerson.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(true));
            var FullyQualifiedNamespacePerson_FirstName = FullyQualifiedNamespacePerson.AddStructuralProperty("FirstName", FullyQualifiedNamespaceNameTypeReference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("Prop.With.Periods", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyDate", EdmCoreModel.Instance.GetDate(false));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyDates", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetDate(true))));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyTimeOfDay", EdmCoreModel.Instance.GetTimeOfDay(false));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyTimeOfDays", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetTimeOfDay(true))));
            FullyQualifiedNamespacePerson.AddStructuralProperty("Birthdate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            FullyQualifiedNamespacePerson.AddStructuralProperty("FavoriteDate", EdmCoreModel.Instance.GetDateTimeOffset(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("TimeEmployed", EdmCoreModel.Instance.GetDuration(true));
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyAddress", FullyQualifiedNamespaceAddressTypeReference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("MyOpenAddress", FullyQualifiedNamespaceOpenAddressTypeReference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("PreviousAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)));
            FullyQualifiedNamespacePerson.AddStructuralProperty("FavoriteColors", new EdmCollectionTypeReference(new EdmCollectionType(colorTypeReference)));
            FullyQualifiedNamespacePerson.AddStructuralProperty("FavoriteNumber", FullyQualifiedNamespaceUInt16Reference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("StockQuantity", FullyQualifiedNamespaceUInt32Reference);
            FullyQualifiedNamespacePerson.AddStructuralProperty("LifeTime", FullyQualifiedNamespaceUInt64Reference);
            FullyQualifiedNamespacePerson.AddKeys(FullyQualifiedNamespacePerson_ID);
            var FullyQualifiedNamespacePerson_MyDog = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyDog", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespaceDog });
            var FullyQualifiedNamespacePerson_MyRelatedDogs = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyFriendsDogs", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespaceDog });
            var FullyQualifiedNamespacePerson_MyPaintings = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyPaintings", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePainting });
            var FullyQualifiedNamespacePerson_MyFavoritePainting = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyFavoritePainting", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespacePainting });
            var FullyQualifiedNamespacePerson_MyLions = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "MyLions",
                TargetMultiplicity = EdmMultiplicity.Many,
                Target = FullyQualifiedNamespaceLion,
                DependentProperties = new List<IEdmStructuralProperty>()
                {
                    FullyQualifiedNamespacePerson_ID
                },
                PrincipalProperties = new List<IEdmStructuralProperty>()
                {
                    FullyQualifiedNamespaceLion_ID1
                }
            });
            FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(
                new EdmNavigationPropertyInfo
                {
                    Name = "MyContainedDog",
                    TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                    Target = FullyQualifiedNamespaceDog,
                    ContainsTarget = true
                });
            FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(
                new EdmNavigationPropertyInfo
                {
                    Name = "MyContainedChimeras",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceChimera,
                    ContainsTarget = true
                });

            var FullyQualifiedNamespacePerson_MyPet2Set = FullyQualifiedNamespacePerson.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyPet2Set", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePet2, });

            model.AddAlternateKeyAnnotation(FullyQualifiedNamespacePerson, new Dictionary<string, IEdmProperty>()
            {
                {"SocialSN", FullyQualifiedNamespacePerson_SSN}
            });

            model.AddAlternateKeyAnnotation(FullyQualifiedNamespacePerson, new Dictionary<string, IEdmProperty>()
            {
                {"NameAlias", FullyQualifiedNamespacePerson_Name},
                {"FirstNameAlias", FullyQualifiedNamespacePerson_FirstName}
            });

            model.AddElement(FullyQualifiedNamespacePerson);

            FullyQualifiedNamespaceEmployee.AddStructuralProperty("WorkEmail", EdmCoreModel.Instance.GetString(true));
            var FullyQualifiedNamespaceEmployee_PaintingsInOffice = FullyQualifiedNamespaceEmployee.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "PaintingsInOffice", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePainting });
            var FullyQualifiedNamespaceEmployee_Manager = FullyQualifiedNamespaceEmployee.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Manager", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespaceManager });
            var FullyQualifiedNamespaceEmployee_OfficeDog = FullyQualifiedNamespaceDog.AddBidirectionalNavigation
                (
                    new EdmNavigationPropertyInfo()
                    {
                        Name = "EmployeeOwner",
                        TargetMultiplicity = EdmMultiplicity.One,
                        Target = FullyQualifiedNamespaceEmployee
                    },

                    new EdmNavigationPropertyInfo()
                    {
                        Name = "OfficeDog",
                        TargetMultiplicity = EdmMultiplicity.One,
                        Target = FullyQualifiedNamespaceDog
                    }
                );
            model.AddElement(FullyQualifiedNamespaceEmployee);

            FullyQualifiedNamespaceManager.AddStructuralProperty("NumberOfReports", EdmCoreModel.Instance.GetInt32(true));
            var FullyQualifiedNamespaceManager_DirectReports = FullyQualifiedNamespaceManager.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "DirectReports", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespaceEmployee });
            model.AddElement(FullyQualifiedNamespaceManager);

            model.AddElement(FullyQualifiedNamespaceOpenEmployee);

            var FullyQualifiedNamespaceDog_ID = FullyQualifiedNamespaceDog.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            FullyQualifiedNamespaceDog.AddStructuralProperty("Color", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceDog.AddStructuralProperty("Nicknames", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            FullyQualifiedNamespaceDog.AddStructuralProperty("Breed", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceDog.AddStructuralProperty("NamedStream", EdmCoreModel.Instance.GetStream(true));
            FullyQualifiedNamespaceDog.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespaceDog_ID, });
            var FullyQualifiedNamespaceDog_MyPeople = FullyQualifiedNamespaceDog.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "MyPeople", TargetMultiplicity = EdmMultiplicity.Many, Target = FullyQualifiedNamespacePerson });
            var FullyQualifiedNamespaceDog_FastestOwner = FullyQualifiedNamespaceDog.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "FastestOwner", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespacePerson });
            var FullyQualifiedNamespaceDog_LionWhoAteMe = FullyQualifiedNamespaceDog.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo()
                {
                    Name = "LionWhoAteMe",
                    TargetMultiplicity = EdmMultiplicity.One,
                    Target = FullyQualifiedNamespaceLion,
                },
                new EdmNavigationPropertyInfo()
                {
                    Name = "DogThatIAte",
                    TargetMultiplicity = EdmMultiplicity.One,
                    Target = FullyQualifiedNamespaceDog,
                    DependentProperties = new List<IEdmStructuralProperty>()
                    { 
                        FullyQualifiedNamespaceLion_ID1
                    },
                    PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        FullyQualifiedNamespaceDog_ID
                    }
                });
            var FullyQualifiedNamespaceDog_LionsISaw = FullyQualifiedNamespaceDog.AddBidirectionalNavigation(
                new EdmNavigationPropertyInfo()
                {
                    Name = "LionsISaw",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceLion,
                },
                new EdmNavigationPropertyInfo()
                {
                    Name = "DogsSeenMe",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceDog,
                    DependentProperties = new List<IEdmStructuralProperty>()
                    { 
                        FullyQualifiedNamespaceLion_ID1
                    },
                    PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        FullyQualifiedNamespaceDog_ID
                    }
                });
            var FullyQualifiedNamespaceLion_Friends = FullyQualifiedNamespaceLion.AddUnidirectionalNavigation(
                new EdmNavigationPropertyInfo()
                {
                    Name = "Friends",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = FullyQualifiedNamespaceLion,
                    DependentProperties = new List<IEdmStructuralProperty>()
                    { 
                        FullyQualifiedNamespaceLion_ID2
                    },
                    PrincipalProperties = new List<IEdmStructuralProperty>()
                    {
                        FullyQualifiedNamespaceLion_ID1
                    }
                });
            model.AddElement(FullyQualifiedNamespaceDog);

            var fullyQualifiedNamespaceChimeraKey1 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Rid", EdmCoreModel.Instance.GetInt32(false));
            var fullyQualifiedNamespaceChimeraKey2 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Gid", EdmPrimitiveTypeKind.Guid);
            var fullyQualifiedNamespaceChimeraKey3 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            var fullyQualifiedNamespaceChimeraKey4 = FullyQualifiedNamespaceChimera.AddStructuralProperty("Upgraded", EdmPrimitiveTypeKind.Boolean);
            FullyQualifiedNamespaceChimera.AddStructuralProperty("Level", EdmPrimitiveTypeKind.Int32);
            FullyQualifiedNamespaceChimera.AddKeys(new IEdmStructuralProperty[] { fullyQualifiedNamespaceChimeraKey1, fullyQualifiedNamespaceChimeraKey2, fullyQualifiedNamespaceChimeraKey3, fullyQualifiedNamespaceChimeraKey4 });
            model.AddElement(FullyQualifiedNamespaceChimera);

            var FullyQualifiedNamespacePainting_ID = FullyQualifiedNamespacePainting.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            FullyQualifiedNamespacePainting.AddStructuralProperty("Artist", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespacePainting.AddStructuralProperty("Value", EdmCoreModel.Instance.GetDecimal(true));
            FullyQualifiedNamespacePainting.AddStructuralProperty("Colors", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            FullyQualifiedNamespacePainting.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespacePainting_ID, });
            var FullyQualifiedNamespacePainting_Owner = FullyQualifiedNamespacePainting.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Owner", TargetMultiplicity = EdmMultiplicity.ZeroOrOne, Target = FullyQualifiedNamespacePerson });
            model.AddElement(FullyQualifiedNamespacePainting);

            FullyQualifiedNamespaceFramedPainting.AddStructuralProperty("FrameColor", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceFramedPainting);

            var FullyQualifiedNamespaceUserAccount_UserName = FullyQualifiedNamespaceUserAccount.AddStructuralProperty("UserName", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceUserAccount.AddKeys(new IEdmStructuralProperty[] { FullyQualifiedNamespaceUserAccount_UserName, });
            model.AddElement(FullyQualifiedNamespaceUserAccount);

            FullyQualifiedNamespaceAddress.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceAddress.AddStructuralProperty("City", EdmCoreModel.Instance.GetString(true));
            FullyQualifiedNamespaceAddress.AddStructuralProperty("NextHome", FullyQualifiedNamespaceAddressTypeReference);
            FullyQualifiedNamespaceAddress.AddStructuralProperty("MyNeighbors", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            model.AddElement(FullyQualifiedNamespaceAddress);

            FullyQualifiedNamespaceHomeAddress.AddStructuralProperty("HomeNO", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceHomeAddress);

            model.AddElement(FullyQualifiedNamespaceOpenAddress);

            FullyQualifiedNamespacePet1.AddKeys(FullyQualifiedNamespacePet1.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int64, false));
            FullyQualifiedNamespacePet1.AddStructuralProperty("SingleID", EdmPrimitiveTypeKind.Single, false);
            FullyQualifiedNamespacePet1.AddStructuralProperty("DoubleID", EdmPrimitiveTypeKind.Double, false);
            FullyQualifiedNamespacePet1.AddStructuralProperty("DecimalID", EdmPrimitiveTypeKind.Decimal, false);
            FullyQualifiedNamespacePet1.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet1);

            FullyQualifiedNamespacePet2.AddKeys(FullyQualifiedNamespacePet2.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Single, false));
            FullyQualifiedNamespacePet2.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            FullyQualifiedNamespacePet2.AddStructuralProperty("PetColorPattern", colorTypeReference);
            model.AddElement(FullyQualifiedNamespacePet2);

            FullyQualifiedNamespacePet3.AddKeys(FullyQualifiedNamespacePet3.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Double, false));
            FullyQualifiedNamespacePet3.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet3);

            FullyQualifiedNamespacePet4.AddKeys(FullyQualifiedNamespacePet4.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Decimal, false));
            FullyQualifiedNamespacePet4.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet4);

            FullyQualifiedNamespacePet5.AddKeys(FullyQualifiedNamespacePet5.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Boolean, false));
            FullyQualifiedNamespacePet5.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet5);

            FullyQualifiedNamespacePet6.AddKeys(FullyQualifiedNamespacePet6.AddStructuralProperty("ID", FullyQualifiedNamespaceIdTypeReference));
            FullyQualifiedNamespacePet6.AddStructuralProperty("Color", EdmPrimitiveTypeKind.String);
            model.AddElement(FullyQualifiedNamespacePet6);
            #endregion

            #region Operations

            var FullyQualifiedNamespaceGetPet1Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet1", FullyQualifiedNamespacePet1TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet1Function.AddParameter("id", EdmCoreModel.Instance.GetInt64(false));
            model.AddElement(FullyQualifiedNamespaceGetPet1Function);

            var FullyQualifiedNamespaceGetPet2Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet2", FullyQualifiedNamespacePet2TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet2Function.AddParameter("id", EdmCoreModel.Instance.GetSingle(false));
            model.AddElement(FullyQualifiedNamespaceGetPet2Function);

            var FullyQualifiedNamespaceGetPet3Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet3", FullyQualifiedNamespacePet3TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet3Function.AddParameter("id", EdmCoreModel.Instance.GetDouble(false));
            model.AddElement(FullyQualifiedNamespaceGetPet3Function);

            var FullyQualifiedNamespaceGetPet4Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet4", FullyQualifiedNamespacePet4TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet4Function.AddParameter("id", EdmCoreModel.Instance.GetDecimal(false));
            model.AddElement(FullyQualifiedNamespaceGetPet4Function);

            var FullyQualifiedNamespaceGetPet5Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet5", FullyQualifiedNamespacePet5TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet5Function.AddParameter("id", EdmCoreModel.Instance.GetBoolean(false));
            model.AddElement(FullyQualifiedNamespaceGetPet5Function);

            var FullyQualifiedNamespaceGetPet6Function = new EdmFunction("Fully.Qualified.Namespace", "GetPet6", FullyQualifiedNamespacePet6TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPet6Function.AddParameter("id", FullyQualifiedNamespaceIdTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPet6Function);

            var FullyQualifiedNamespaceGetPetCountFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPetCount", FullyQualifiedNamespacePet5TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPetCountFunction.AddParameter("colorPattern", colorTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPetCountFunction);

            var FullyQualifiedNamespaceTryGetPetCountFunction = new EdmFunction("Fully.Qualified.Namespace", "TryGetPetCount", FullyQualifiedNamespacePet5TypeReference, false, null, true);
            FullyQualifiedNamespaceGetPetCountFunction.AddParameter("colorPattern", nullableColorTypeReference);
            model.AddElement(FullyQualifiedNamespaceTryGetPetCountFunction);

            var FullyQualifiedNamespaceWalkAction = new EdmAction("Fully.Qualified.Namespace", "Walk", FullyQualifiedNamespaceAddressTypeReference, true, null);
            FullyQualifiedNamespaceWalkAction.AddParameter("dog", FullyQualifiedNamespaceDogTypeReference);
            model.AddElement(FullyQualifiedNamespaceWalkAction);

            var FullyQualifiedNamespaceFindMyOwnerFunction = new EdmFunction("Fully.Qualified.Namespace", "FindMyOwner", FullyQualifiedNamespacePersonTypeReference, false, null, false);
            FullyQualifiedNamespaceFindMyOwnerFunction.AddParameter("dogsName", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceFindMyOwnerFunction);

            var FullyQualifiedNamespaceHasHatFunction = new EdmFunction("Fully.Qualified.Namespace", "HasHat", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasHatFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceHasHatFunction);

            var FullyQualifiedNamespaceHasHatFunction2 = new EdmFunction("Fully.Qualified.Namespace", "HasHat", EdmCoreModel.Instance.GetInt32(true), true, null, false);
            FullyQualifiedNamespaceHasHatFunction2.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceHasHatFunction2.AddParameter("onCat", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceHasHatFunction2);

            var FullyQualifiedNamespaceHasJobFunction = new EdmFunction("Fully.Qualified.Namespace", "HasJob", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasJobFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceHasJobFunction);

            var FullyQualifiedNamespaceAllHaveDogFunction = new EdmFunction("Fully.Qualified.Namespace", "AllHaveDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceAllHaveDogFunction.AddParameter("people", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)));
            model.AddElement(FullyQualifiedNamespaceAllHaveDogFunction);

            var FullyQualifiedNamespaceAllHaveDogFunction2 = new EdmFunction("Fully.Qualified.Namespace", "AllHaveDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceAllHaveDogFunction2.AddParameter("people", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)));
            FullyQualifiedNamespaceAllHaveDogFunction2.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceAllHaveDogFunction2);

            var FullyQualifiedNamespaceFireAllAction = new EdmAction("Fully.Qualified.Namespace", "FireAll", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceFireAllAction.AddParameter("employees", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)));
            model.AddElement(FullyQualifiedNamespaceFireAllAction);

            var FullyQualifiedNamespaceHasDogFunction = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceHasDogFunction);

            var FullyQualifiedNamespaceHasDogFunction2 = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction2.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceHasDogFunction2.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceHasDogFunction2);

            var FullyQualifiedNamespaceHasDogFunction3 = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction3.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceHasDogFunction3.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            FullyQualifiedNamespaceHasDogFunction3.AddParameter("name", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceHasDogFunction3);

            var FullyQualifiedNamespaceHasDogFunction4 = new EdmFunction("Fully.Qualified.Namespace", "HasDog", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceHasDogFunction4.AddParameter("person", FullyQualifiedNamespaceEmployeeTypeReference);
            FullyQualifiedNamespaceHasDogFunction4.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceHasDogFunction4);

            var FullyQualifiedNamespaceGetMyDogFunction = new EdmFunction("Fully.Qualified.Namespace", "GetMyDog", FullyQualifiedNamespaceDogTypeReference, true, new EdmPathExpression("person/MyDog"), true);
            FullyQualifiedNamespaceGetMyDogFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetMyDogFunction);

            var FullyQualifiedNamespaceAllMyFriendsDogsFunction = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogs", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, new EdmPathExpression("person/MyFriendsDogs"), true);
            FullyQualifiedNamespaceAllMyFriendsDogsFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogsFunction);

            var FullyQualifiedNamespaceAllMyFriendsDogsNonComposableFunction = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogsNonComposable", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, new EdmPathExpression("person/MyFriendsDogs"), false);
            FullyQualifiedNamespaceAllMyFriendsDogsNonComposableFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogsNonComposableFunction);

            var FullyQualifiedNamespaceAllMyFriendsDogsFunction2 = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogs", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, new EdmPathExpression("person/MyFriendsDogs"), true);
            FullyQualifiedNamespaceAllMyFriendsDogsFunction2.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceAllMyFriendsDogsFunction2.AddParameter("inOffice", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogsFunction2);

            var FullyQualifiedNamespaceAllMyFriendsDogs_NoSetFunction = new EdmFunction("Fully.Qualified.Namespace", "AllMyFriendsDogs_NoSet", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)), true, null, false);
            FullyQualifiedNamespaceAllMyFriendsDogs_NoSetFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceAllMyFriendsDogs_NoSetFunction);

            var FullyQualifiedNamespaceOwnerOfFastestDogFunction = new EdmFunction("Fully.Qualified.Namespace", "OwnerOfFastestDog", FullyQualifiedNamespacePersonTypeReference, true, new EdmPathExpression("dogs/FastestOwner"), true);
            FullyQualifiedNamespaceOwnerOfFastestDogFunction.AddParameter("dogs", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceDogTypeReference)));
            model.AddElement(FullyQualifiedNamespaceOwnerOfFastestDogFunction);

            var FullyQualifiedNamespaceOwnsTheseDogsFunction = new EdmFunction("Fully.Qualified.Namespace", "OwnsTheseDogs", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceOwnsTheseDogsFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceOwnsTheseDogsFunction.AddParameter("dogNames", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            model.AddElement(FullyQualifiedNamespaceOwnsTheseDogsFunction);

            var FullyQualifiedNamespaceIsInTheUSFunction = new EdmFunction("Fully.Qualified.Namespace", "IsInTheUS", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsInTheUSFunction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            model.AddElement(FullyQualifiedNamespaceIsInTheUSFunction);

            var FullyQualifiedNamespaceMoveAction = new EdmAction("Fully.Qualified.Namespace", "Move", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceMoveAction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceMoveAction.AddParameter("streetAddress", EdmCoreModel.Instance.GetString(true));

            var FullyQualifiedNamespaceCanMoveToAddressFunction = new EdmFunction("Fully.Qualified.Namespace", "CanMoveToAddress", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceCanMoveToAddressFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceCanMoveToAddressFunction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            model.AddElement(FullyQualifiedNamespaceCanMoveToAddressFunction);

            var FullyQualifiedNamespaceIsAddressGoodFunction = new EdmFunction("Fully.Qualified.Namespace", "IsAddressGood", EdmCoreModel.Instance.GetBoolean(true), false, null, false);
            FullyQualifiedNamespaceIsAddressGoodFunction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            model.AddElement(FullyQualifiedNamespaceIsAddressGoodFunction);

            var FullyQualifiedNamespaceCanMoveToAddressesFunction = new EdmFunction("Fully.Qualified.Namespace", "CanMoveToAddresses", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceCanMoveToAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceCanMoveToAddressesFunction.AddParameter("addresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)));
            model.AddElement(FullyQualifiedNamespaceCanMoveToAddressesFunction);

            var FullyQualifiedNamespaceIsOlderThanByteFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanByte", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanByteFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanByteFunction.AddParameter("age", EdmCoreModel.Instance.GetByte(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanByteFunction);

            var FullyQualifiedNamespaceIsOlderThanSByteFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanSByte", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanSByteFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanSByteFunction.AddParameter("age", EdmCoreModel.Instance.GetSByte(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanSByteFunction);

            var FullyQualifiedNamespaceIsOlderThanShortFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanShort", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanShortFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanShortFunction.AddParameter("age", EdmCoreModel.Instance.GetInt16(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanShortFunction);

            var FullyQualifiedNamespaceIsOlderThanSingleFunction = new EdmFunction("Fully.Qualified.Namespace", "IsOlderThanSingle", EdmCoreModel.Instance.GetBoolean(true), true, null, false);
            FullyQualifiedNamespaceIsOlderThanSingleFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceIsOlderThanSingleFunction.AddParameter("age", EdmCoreModel.Instance.GetSingle(true));
            model.AddElement(FullyQualifiedNamespaceIsOlderThanSingleFunction);

            var FullyQualifiedNamespacePaintAction = new EdmAction("Fully.Qualified.Namespace", "Paint", FullyQualifiedNamespacePaintingTypeReference, true, new EdmPathExpression("person/MyPaintings"));
            FullyQualifiedNamespacePaintAction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespacePaintAction);

            var FullyQualifiedNamespaceMoveAction2 = new EdmAction("Fully.Qualified.Namespace", "Move", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceMoveAction2.AddParameter("employee", FullyQualifiedNamespaceEmployeeTypeReference);
            FullyQualifiedNamespaceMoveAction2.AddParameter("building", EdmCoreModel.Instance.GetInt32(true));
            FullyQualifiedNamespaceMoveAction2.AddParameter("room", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceMoveAction2);

            var FullyQualifiedNamespaceRestoreAction = new EdmAction("Fully.Qualified.Namespace", "Restore", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceRestoreAction.AddParameter("painting", FullyQualifiedNamespacePaintingTypeReference);
            model.AddElement(FullyQualifiedNamespaceRestoreAction);

            var FullyQualifiedNamespaceChangeStateAction = new EdmAction("Fully.Qualified.Namespace", "ChangeState", EdmCoreModel.Instance.GetBoolean(true), true, null);
            FullyQualifiedNamespaceChangeStateAction.AddParameter("address", FullyQualifiedNamespaceAddressTypeReference);
            FullyQualifiedNamespaceChangeStateAction.AddParameter("newState", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceChangeStateAction);

            var FullyQualifiedNamespaceGetMyPersonFunction = new EdmFunction("Fully.Qualified.Namespace", "GetMyPerson", FullyQualifiedNamespacePersonTypeReference, true, null, false);
            FullyQualifiedNamespaceGetMyPersonFunction.AddParameter("dog", FullyQualifiedNamespaceDogTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetMyPersonFunction);
            model.AddElement(FullyQualifiedNamespaceMoveAction);

            var FullyQualifiedNamespaceGetCoolPeopleAction = new EdmFunction("Fully.Qualified.Namespace", "GetCoolPeople", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)), false, null, true /*isComposable*/);
            FullyQualifiedNamespaceGetCoolPeopleAction.AddParameter("id", EdmCoreModel.Instance.GetInt32(true));
            FullyQualifiedNamespaceGetCoolPeopleAction.AddParameter("limit", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetCoolPeopleAction);

            var FullyQualifiedNamespaceGetHotPeopleAction = new EdmFunction("Fully.Qualified.Namespace", "GetHotPeople", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespacePersonTypeReference)), true, new EdmPathExpression("person"), true /*isComposable*/);
            FullyQualifiedNamespaceGetHotPeopleAction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceGetHotPeopleAction.AddParameter("limit", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetHotPeopleAction);

            var FullyQualifiedNamespaceGetCoolestPersonAction = new EdmFunction("Fully.Qualified.Namespace", "GetCoolestPerson", FullyQualifiedNamespacePersonTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetCoolestPersonAction);

            var FullyQualifiedNamespaceGetCoolestPersonWithStyleAction = new EdmFunction("Fully.Qualified.Namespace", "GetCoolestPersonWithStyle", FullyQualifiedNamespacePersonTypeReference, false, null, true /*isComposable*/);
            FullyQualifiedNamespaceGetCoolestPersonWithStyleAction.AddParameter("styleID", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetCoolestPersonWithStyleAction);

            var FullyQualifiedNamespaceGetBestManagerAction = new EdmFunction("Fully.Qualified.Namespace", "GetBestManager", FullyQualifiedNamespaceManagerTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetBestManagerAction);

            var FullyQualifiedNamespaceGetNothingAction = new EdmAction("Fully.Qualified.Namespace", "GetNothing", null, false, null);
            model.AddElement(FullyQualifiedNamespaceGetNothingAction);

            var FullyQualifiedNamespaceGetSomeNumberAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeNumber", EdmCoreModel.Instance.GetInt32(true), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeNumberAction);

            var FullyQualifiedNamespaceGetSomeAddressAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeAddress", FullyQualifiedNamespaceAddressTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeAddressAction);

            var FullyQualifiedNamespaceGetSomeNumbersAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt32(true))), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeNumbersAction);

            var FullyQualifiedNamespaceGetSomeColorsFunction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeColors", new EdmCollectionTypeReference(new EdmCollectionType(colorTypeReference)), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeColorsFunction);

            var FullyQualifiedNamespaceGetSomeColorFunction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeColor", colorTypeReference, false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeColorFunction);

            var FullyQualifiedNamespaceGetSomeAddressesAction = new EdmFunction("Fully.Qualified.Namespace", "GetSomeAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)), false, null, true /*isComposable*/);
            model.AddElement(FullyQualifiedNamespaceGetSomeAddressesAction);

            var FullyQualifiedNamespaceResetAllDataAction = new EdmAction("Fully.Qualified.Namespace", "ResetAllData", null, false, null);
            model.AddElement(FullyQualifiedNamespaceResetAllDataAction);

            var FullyQualifiedNamespaceGetMostImporantPersonFunction = new EdmFunction("Fully.Qualified.Namespace", "GetMostImporantPerson", FullyQualifiedNamespacePersonTypeReference, false, null, false);
            model.AddElement(FullyQualifiedNamespaceGetMostImporantPersonFunction);

            var FullyQualifiedNamespaceGetMostImporantPersonFunction2 = new EdmFunction("Fully.Qualified.Namespace", "GetMostImporantPerson", FullyQualifiedNamespacePersonTypeReference, false, null, false);
            FullyQualifiedNamespaceGetMostImporantPersonFunction2.AddParameter("city", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceGetMostImporantPersonFunction2);

            var FullyQualifiedNamespaceGetPriorNumbersFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPriorNumbers", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt32(true))), true, null, true);
            FullyQualifiedNamespaceGetPriorNumbersFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPriorNumbersFunction);

            var FullyQualifiedNamespaceGetPriorAddressesFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPriorAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)), true, null, true);
            FullyQualifiedNamespaceGetPriorAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPriorAddressesFunction);

            var FullyQualifiedNamespaceGetPriorAddressFunction = new EdmFunction("Fully.Qualified.Namespace", "GetPriorAddress", FullyQualifiedNamespaceAddressTypeReference, true, null, true);
            FullyQualifiedNamespaceGetPriorAddressFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetPriorAddressFunction);

            var FullyQualifiedNamespaceGetFavoriteColorsFunction = new EdmFunction("Fully.Qualified.Namespace", "GetFavoriteColors", new EdmCollectionTypeReference(new EdmCollectionType(colorTypeReference)), true, null, true);
            FullyQualifiedNamespaceGetFavoriteColorsFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetFavoriteColorsFunction);

            var FullyQualifiedNamespaceGetFavoriteColorFunction = new EdmFunction("Fully.Qualified.Namespace", "GetFavoriteColor", colorTypeReference, true, null, true);
            FullyQualifiedNamespaceGetFavoriteColorFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetFavoriteColorFunction);

            var FullyQualifiedNamespaceGetNearbyPriorAddressesFunction = new EdmFunction("Fully.Qualified.Namespace", "GetNearbyPriorAddresses", new EdmCollectionTypeReference(new EdmCollectionType(FullyQualifiedNamespaceAddressTypeReference)), true, null, false);
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("currentLocation", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeographyPoint, true));
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("limit", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(FullyQualifiedNamespaceGetNearbyPriorAddressesFunction);

            var FullyQualifiedNamespaceGetColorAtPositionFunction = new EdmFunction("Fully.Qualified.Namespace", "GetColorAtPosition", EdmCoreModel.Instance.GetString(true), true, null, false);
            FullyQualifiedNamespaceGetColorAtPositionFunction.AddParameter("painting", FullyQualifiedNamespacePaintingTypeReference);
            FullyQualifiedNamespaceGetColorAtPositionFunction.AddParameter("position", EdmCoreModel.Instance.GetSpatial(EdmPrimitiveTypeKind.GeometryPoint, true));
            FullyQualifiedNamespaceGetColorAtPositionFunction.AddParameter("includeAlpha", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(FullyQualifiedNamespaceGetColorAtPositionFunction);

            var FullyQualifiedNamespaceMoveEveryoneAction = new EdmAction("Fully.Qualified.Namespace", "MoveEveryone", EdmCoreModel.Instance.GetBoolean(true), false, null);
            FullyQualifiedNamespaceMoveEveryoneAction.AddParameter("streetAddress", EdmCoreModel.Instance.GetString(true));
            model.AddElement(FullyQualifiedNamespaceMoveEveryoneAction);

            var FullyQualifiedNamespaceGetFullNameFunction = new EdmFunction("Fully.Qualified.Namespace", "GetFullName", FullyQualifiedNamespaceNameTypeReference, true, null, true);
            FullyQualifiedNamespaceGetNearbyPriorAddressesFunction.AddParameter("person", FullyQualifiedNamespacePersonTypeReference);
            FullyQualifiedNamespaceGetFullNameFunction.AddParameter("nickname", FullyQualifiedNamespaceNameTypeReference);
            model.AddElement(FullyQualifiedNamespaceGetFullNameFunction);

            #endregion

            #region Context Container

            var FullyQualifiedNamespaceContext = new EdmEntityContainer("Fully.Qualified.Namespace", "Context");
            model.AddElement(FullyQualifiedNamespaceContext);

            var FullyQualifiedNamespaceContextPeople = FullyQualifiedNamespaceContext.AddEntitySet("People", FullyQualifiedNamespacePerson);
            var FullyQualifiedNamespaceContextDogs = FullyQualifiedNamespaceContext.AddEntitySet("Dogs", FullyQualifiedNamespaceDog);
            var FullyQualifiedNamespaceContextLions = FullyQualifiedNamespaceContext.AddEntitySet("Lions", FullyQualifiedNamespaceLion);
            var FullyQualifiedNamespaceContextPaintings = FullyQualifiedNamespaceContext.AddEntitySet("Paintings", FullyQualifiedNamespacePainting);
            var FullyQualifiedNamespaceContextUsers = FullyQualifiedNamespaceContext.AddEntitySet("Users", FullyQualifiedNamespaceUserAccount);
            var FullyQualifiedNamespaceContextPet1Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet1Set", FullyQualifiedNamespacePet1);
            var FullyQualifiedNamespaceContextPet2Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet2Set", FullyQualifiedNamespacePet2);
            var FullyQualifiedNamespaceContextPet3Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet3Set", FullyQualifiedNamespacePet3);
            var FullyQualifiedNamespaceContextPet4Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet4Set", FullyQualifiedNamespacePet4);
            var FullyQualifiedNamespaceContextPet5Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet5Set", FullyQualifiedNamespacePet5);
            var FullyQualifiedNamespaceContextPet6Set = FullyQualifiedNamespaceContext.AddEntitySet("Pet6Set", FullyQualifiedNamespacePet6);
            var FullyQualifiedNamespaceContextChimera = FullyQualifiedNamespaceContext.AddEntitySet("Chimeras", FullyQualifiedNamespaceChimera);

            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyDog, FullyQualifiedNamespaceContextDogs);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyRelatedDogs, FullyQualifiedNamespaceContextDogs);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyLions, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPaintings, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyFavoritePainting, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceEmployee_PaintingsInOffice, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceEmployee_Manager, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespaceManager_DirectReports, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextPeople.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPet2Set, FullyQualifiedNamespaceContextPet2Set);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_MyPeople, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_FastestOwner, FullyQualifiedNamespaceContextPeople);
            FullyQualifiedNamespaceContextDogs.AddNavigationTarget(FullyQualifiedNamespaceDog_LionsISaw, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextLions.AddNavigationTarget(FullyQualifiedNamespaceLion_Friends, FullyQualifiedNamespaceContextLions);
            FullyQualifiedNamespaceContextPaintings.AddNavigationTarget(FullyQualifiedNamespacePainting_Owner, FullyQualifiedNamespaceContextPeople);

            // Add singleton
            var FullQualifiedNamespaceSingletonBoss = FullyQualifiedNamespaceContext.AddSingleton("Boss", FullyQualifiedNamespacePerson);
            FullQualifiedNamespaceSingletonBoss.AddNavigationTarget(FullyQualifiedNamespacePerson_MyDog, FullyQualifiedNamespaceContextDogs);
            FullQualifiedNamespaceSingletonBoss.AddNavigationTarget(FullyQualifiedNamespacePerson_MyPaintings, FullyQualifiedNamespaceContextPaintings);
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet1", FullyQualifiedNamespaceGetPet1Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet1Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet2", FullyQualifiedNamespaceGetPet2Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet2Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet3", FullyQualifiedNamespaceGetPet3Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet3Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet4", FullyQualifiedNamespaceGetPet4Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet4Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet5", FullyQualifiedNamespaceGetPet5Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet5Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPet6", FullyQualifiedNamespaceGetPet6Function, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet6Set));
            FullyQualifiedNamespaceContext.AddFunctionImport("GetPetCount", FullyQualifiedNamespaceGetPetCountFunction, new EdmEntitySetReferenceExpression(FullyQualifiedNamespaceContextPet5Set));

            FullyQualifiedNamespaceContext.AddFunctionImport("FindMyOwner", FullyQualifiedNamespaceFindMyOwnerFunction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("IsAddressGood", FullyQualifiedNamespaceIsAddressGoodFunction, null);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolPeople", FullyQualifiedNamespaceGetCoolPeopleAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolestPerson", FullyQualifiedNamespaceGetCoolestPersonAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetCoolestPersonWithStyle", FullyQualifiedNamespaceGetCoolestPersonWithStyleAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddFunctionImport("GetBestManager", FullyQualifiedNamespaceGetBestManagerAction, new EdmEntitySetReferenceExpression(model.FindEntityContainer("Fully.Qualified.Namespace.Context").FindEntitySet("People")));

            FullyQualifiedNamespaceContext.AddActionImport("GetNothing", FullyQualifiedNamespaceGetNothingAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeNumber", FullyQualifiedNamespaceGetSomeNumberAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeAddress", FullyQualifiedNamespaceGetSomeAddressAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeNumbers", FullyQualifiedNamespaceGetSomeNumbersAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetSomeAddresses", FullyQualifiedNamespaceGetSomeAddressesAction);

            FullyQualifiedNamespaceContext.AddActionImport("ResetAllData", FullyQualifiedNamespaceResetAllDataAction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetMostImporantPerson", FullyQualifiedNamespaceGetMostImporantPersonFunction);

            FullyQualifiedNamespaceContext.AddFunctionImport("GetMostImporantPerson", FullyQualifiedNamespaceGetMostImporantPersonFunction2);

            FullyQualifiedNamespaceContext.AddActionImport("MoveEveryone", FullyQualifiedNamespaceMoveEveryoneAction);

            #endregion

            try
            {
                // serialize edm
                XDocument document = new XDocument();
                IEnumerable<EdmError> errors;
                using (var writer = document.CreateWriter())
                {
                    EdmxWriter.TryWriteEdmx(model, writer, EdmxTarget.OData, out errors).Should().BeTrue();
                }

                string doc = document.ToString();

                // deserialize edm xml
                // TODO: remove the above model building codes.
                IEdmModel parsedModel;
                if (EdmxReader.TryParse(XmlReader.Create(new StringReader(HardCodedTestModelXml.MainModelXml)), (Uri uri) =>
                {
                    if (string.Equals(uri.AbsoluteUri, "http://submodel1/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml1));
                    }
                    else if (string.Equals(uri.AbsoluteUri, "http://submodel2/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml2));
                    }
                    else if (string.Equals(uri.AbsoluteUri, "http://submodel3/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml3));
                    }
                    else if (string.Equals(uri.AbsoluteUri, "http://submodel4/"))
                    {
                        return XmlReader.Create(new StringReader(HardCodedTestModelXml.SubModelXml4));
                    }

                    throw new Exception("edmx:refernece must have a valid url." + uri.AbsoluteUri);
                }, out parsedModel, out errors))
                {
                   return parsedModel;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return null;
        }
        private static IEdmActionImport AddUnboundAction(EdmEntityContainer container, string name, IEdmEntityType bindingType, bool isCollection)
        {
            var action = new EdmAction(
                container.Namespace, name, returnType: null, isBound: true, entitySetPathExpression: null);

            IEdmTypeReference bindingParamterType = new EdmEntityTypeReference(bindingType, isNullable: false);
            if (isCollection)
            {
                bindingParamterType = new EdmCollectionTypeReference(new EdmCollectionType(bindingParamterType));
            }

            action.AddParameter("bindingParameter", bindingParamterType);
            var actionImport = container.AddActionImport(action);
            return actionImport;
        }
        public static IEdmModel CreateODataServiceModel(string ns)
        {
            EdmModel model = new EdmModel();
            var defaultContainer = new EdmEntityContainer(ns, "OperationService");
            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);

            #endregion

            #region EnumType

            var customerLevelType = new EdmEnumType(ns, "CustomerLevel");
            customerLevelType.AddMember("Common", new EdmIntegerConstant(0));
            customerLevelType.AddMember("Silver", new EdmIntegerConstant(1));
            customerLevelType.AddMember("Gold", new EdmIntegerConstant(2));
            model.AddElement(customerLevelType);

            #endregion

            #region EntityType

            var customerType = new EdmEntityType(ns, "Customer");
            var customerIdProperty = new EdmStructuralProperty(customerType, "ID", EdmCoreModel.Instance.GetInt32(false));
            customerType.AddProperty(customerIdProperty);
            customerType.AddKeys(customerIdProperty);
            customerType.AddStructuralProperty("FirstName", EdmCoreModel.Instance.GetString(false));
            customerType.AddStructuralProperty("LastName", EdmCoreModel.Instance.GetString(false));
            customerType.AddStructuralProperty("Address", new EdmComplexTypeReference(addressType, true));
            customerType.AddStructuralProperty("Emails", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            customerType.AddStructuralProperty("Level", new EdmEnumTypeReference(customerLevelType, false));
            model.AddElement(customerType);

            var orderType = new EdmEntityType(ns, "Order");
            var orderIdProperty = new EdmStructuralProperty(orderType, "ID", EdmCoreModel.Instance.GetInt32(false));
            orderType.AddProperty(orderIdProperty);
            orderType.AddKeys(orderIdProperty);
            orderType.AddStructuralProperty("OrderDate", EdmCoreModel.Instance.GetDateTimeOffset(false));
            orderType.AddStructuralProperty("Notes", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(true))));
            model.AddElement(orderType);

            var ordersNavigation = customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Orders",
                Target = orderType,
                TargetMultiplicity = EdmMultiplicity.Many
            });

            var customerForOrderNavigation = orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
            {
                Name = "Customer",
                Target = customerType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            #endregion

            #region EntitySet

            var customerSet = new EdmEntitySet(defaultContainer, "Customers", customerType);
            defaultContainer.AddElement(customerSet);

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

            customerSet.AddNavigationTarget(ordersNavigation, orderSet);
            orderSet.AddNavigationTarget(customerForOrderNavigation, customerSet);

            #endregion

            #region Operations

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

            var customerTypeReference = new EdmEntityTypeReference(customerType, true);
            var customerCollectionTypeReference =
                new EdmCollectionTypeReference(new EdmCollectionType(customerTypeReference));
            var addressTypeReference = new EdmComplexTypeReference(addressType, true);
            var addressCollectionTypeRefernce =
                new EdmCollectionTypeReference(new EdmCollectionType(addressTypeReference));
            var stringTypeReference = EdmCoreModel.Instance.GetString(true);
            var stringCollectionTypeReference =
                new EdmCollectionTypeReference(new EdmCollectionType(stringTypeReference));
            var orderTypeReference = new EdmEntityTypeReference(orderType, true);
            var orderCollectionTypeReference =
               new EdmCollectionTypeReference(new EdmCollectionType(orderTypeReference));

            //Bound Function : Bound to Collection Of Entity, Parameter is Complex Value, Return Entity.
            var getCustomerForAddressFunction = new EdmFunction(ns, "GetCustomerForAddress", customerTypeReference, true, new EdmPathExpression("customers"), true);
            getCustomerForAddressFunction.AddParameter("customers", customerCollectionTypeReference);
            getCustomerForAddressFunction.AddParameter("address", addressTypeReference);
            model.AddElement(getCustomerForAddressFunction);

            //Bound Function : Bound to Collection Of Entity, Parameter is Collection of Complex Value, Return Collection Of Entity.
            var getCustomersForAddressesFunction = new EdmFunction(ns, "GetCustomersForAddresses", customerCollectionTypeReference, true, new EdmPathExpression("customers"), true);
            getCustomersForAddressesFunction.AddParameter("customers", customerCollectionTypeReference);
            getCustomersForAddressesFunction.AddParameter("addresses", addressCollectionTypeRefernce);
            model.AddElement(getCustomersForAddressesFunction);

            //Bound Function : Bound to Collection Of Entity, Parameter is Collection of Complex Value, Return Entity
            var getCustomerForAddressesFunction = new EdmFunction(ns, "GetCustomerForAddresses", customerTypeReference, true, new EdmPathExpression("customers"), true);
            getCustomerForAddressesFunction.AddParameter("customers", customerCollectionTypeReference);
            getCustomerForAddressesFunction.AddParameter("addresses", addressCollectionTypeRefernce);
            model.AddElement(getCustomerForAddressesFunction);

            //Bound Function : Bound to Entity, Return Complex Value
            var getCustomerAddressFunction = new EdmFunction(ns, "GetCustomerAddress", addressTypeReference, true, null, true);
            getCustomerAddressFunction.AddParameter("customer", customerTypeReference);
            model.AddElement(getCustomerAddressFunction);

            //Bound Function : Bound to Entity, Parameter is Complex Value, Return Entity
            var verifyCustomerAddressFunction = new EdmFunction(ns, "VerifyCustomerAddress", customerTypeReference, true, new EdmPathExpression("customer"), true);
            verifyCustomerAddressFunction.AddParameter("customer", customerTypeReference);
            verifyCustomerAddressFunction.AddParameter("addresses", addressTypeReference);
            model.AddElement(verifyCustomerAddressFunction);

            //Bound Function : Bound to Entity, Parameter is Entity, Return Entity
            var verifyCustomerByOrderFunction = new EdmFunction(ns, "VerifyCustomerByOrder", customerTypeReference, true, new EdmPathExpression("customer"), true);
            verifyCustomerByOrderFunction.AddParameter("customer", customerTypeReference);
            verifyCustomerByOrderFunction.AddParameter("order", orderTypeReference);
            model.AddElement(verifyCustomerByOrderFunction);

            //Bound Function : Bound to Entity, Parameter is Collection of String, Return Collection of Entity
            var getOrdersFromCustomerByNotesFunction = new EdmFunction(ns, "GetOrdersFromCustomerByNotes", orderCollectionTypeReference, true, new EdmPathExpression("customer/Orders"), true);
            getOrdersFromCustomerByNotesFunction.AddParameter("customer", customerTypeReference);
            getOrdersFromCustomerByNotesFunction.AddParameter("notes", stringCollectionTypeReference);
            model.AddElement(getOrdersFromCustomerByNotesFunction);

            //Bound Function : Bound to Collection Of Entity, Parameter is String, Return Collection of Entity
            var getOrdersByNoteFunction = new EdmFunction(ns, "GetOrdersByNote", orderCollectionTypeReference, true, new EdmPathExpression("orders"), true);
            getOrdersByNoteFunction.AddParameter("orders", orderCollectionTypeReference);
            getOrdersByNoteFunction.AddParameter("note", stringTypeReference);
            model.AddElement(getOrdersByNoteFunction);

            //Bound Function : Bound to Collection Of Entity, Parameter is Collection of String, Return Entity
            var getOrderByNoteFunction = new EdmFunction(ns, "GetOrderByNote", orderTypeReference, true, new EdmPathExpression("orders"), true);
            getOrderByNoteFunction.AddParameter("orders", orderCollectionTypeReference);
            getOrderByNoteFunction.AddParameter("notes", stringCollectionTypeReference);
            model.AddElement(getOrderByNoteFunction);

            //Bound Function : Bound to Collection Of Entity, Parameter is Collection of Entity, Return Collection Of Entity
            var getCustomersByOrdersFunction = new EdmFunction(ns, "GetCustomersByOrders", customerCollectionTypeReference, true, new EdmPathExpression("customers"), true);
            getCustomersByOrdersFunction.AddParameter("customers", customerCollectionTypeReference);
            getCustomersByOrdersFunction.AddParameter("orders", orderCollectionTypeReference);
            model.AddElement(getCustomersByOrdersFunction);

            //Bound Function : Bound to Collection Of Entity, Parameter is Entity, Return Entity
            var getCustomerByOrderFunction = new EdmFunction(ns, "GetCustomerByOrder", customerTypeReference, true, new EdmPathExpression("customers"), true);
            getCustomerByOrderFunction.AddParameter("customers", customerCollectionTypeReference);
            getCustomerByOrderFunction.AddParameter("order", orderTypeReference);
            model.AddElement(getCustomerByOrderFunction);

            // Function Import: Parameter is Collection of Entity, Return Collection Of Entity
            var getCustomersByOrdersUnboundFunction = new EdmFunction(ns, "GetCustomersByOrders", customerCollectionTypeReference, false, null, true);
            getCustomersByOrdersUnboundFunction.AddParameter("orders", orderCollectionTypeReference);
            model.AddElement(getCustomersByOrdersUnboundFunction);
            defaultContainer.AddFunctionImport(getCustomersByOrdersUnboundFunction.Name, getCustomersByOrdersUnboundFunction, new EdmEntitySetReferenceExpression(customerSet));

            // Function Import: Parameter is Collection of Entity, Return Entity
            var getCustomerByOrderUnboundFunction = new EdmFunction(ns, "GetCustomerByOrder", customerTypeReference, false, null, true);
            getCustomerByOrderUnboundFunction.AddParameter("order", orderTypeReference);
            model.AddElement(getCustomerByOrderUnboundFunction);
            defaultContainer.AddFunctionImport(getCustomerByOrderUnboundFunction.Name, getCustomerByOrderUnboundFunction, new EdmEntitySetReferenceExpression(customerSet));

            // Function Import: Bound to Entity, Return Complex Value
            var getCustomerAddressUnboundFunction = new EdmFunction(ns, "GetCustomerAddress", addressTypeReference, false, null, true);
            getCustomerAddressUnboundFunction.AddParameter("customer", customerTypeReference);
            model.AddElement(getCustomerAddressUnboundFunction);
            defaultContainer.AddFunctionImport(getCustomerAddressUnboundFunction.Name, getCustomerAddressUnboundFunction);

            #endregion

            IEnumerable<EdmError> errors;
            model.Validate(out errors);
            if (errors.Any())
            {
                throw new SystemException("The model is not valid, please correct it");
            }

            return model;
        }
        public static IEdmModel OperationImportNameSimpleIdentifier()
        {
            var model = new EdmModel();
            var container = new EdmEntityContainer("Default", "Container");

            var function1 = new EdmFunction("Default", "Function1", EdmCoreModel.Instance.GetInt32(false));
            var function2 = new EdmFunction("Default", "Function2", EdmCoreModel.Instance.GetInt32(false));
            var function3 = new EdmFunction("Default", "Function3", EdmCoreModel.Instance.GetInt32(false));
            var function4 = new EdmFunction("Default", "Function4", EdmCoreModel.Instance.GetInt32(false));
            container.AddFunctionImport("ValidName", function1);
            container.AddFunctionImport("_!@#$%^&*()", function2);
            container.AddFunctionImport("   ", function3);
            container.AddFunctionImport(string.Empty, function4);

            var action1 = new EdmAction("Default", "Action1", EdmCoreModel.Instance.GetInt32(false));
            var action2 = new EdmAction("Default", "Action2", EdmCoreModel.Instance.GetInt32(false));
            model.AddElement(action1);
            model.AddElement(action2);
            container.AddActionImport(new string('F', 480), action1);
            container.AddActionImport(new string('F', 481), action2);

            model.AddElement(container);
            model.AddElement(function1);
            model.AddElement(function2);
            model.AddElement(function3);
            model.AddElement(function4);
            return model;
        }
        private static IEdmEntitySetBase GetTargetEntitySet(EdmPathExpression edmPathExpression, out IEdmEntitySet targetEntitySet, bool addParameters = false, bool isBindable = true)
        {
            var model = new EdmModel();
            var container = new EdmEntityContainer("Fake", "Container");
            model.AddElement(container);
            var edmEntityType = new EdmEntityType("Fake", "EntityType");

            var sourceEntitySet = container.AddEntitySet("SourceEntitySet", edmEntityType);
            var middleEntitySet = container.AddEntitySet("MiddleEntitySet", edmEntityType);
            targetEntitySet = container.AddEntitySet("TargetEntitySet", edmEntityType);

            var nav1 = edmEntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Navigation1", Target = edmEntityType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
            var nav2 = edmEntityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Navigation2", Target = edmEntityType, TargetMultiplicity = EdmMultiplicity.Many });

            sourceEntitySet.AddNavigationTarget(nav1, middleEntitySet);
            middleEntitySet.AddNavigationTarget(nav2, targetEntitySet);

            var action = new EdmAction("Fake", "FakeAction", new EdmEntityTypeReference(edmEntityType, false), isBindable, null /*EntitySetPath*/);
            if (addParameters)
            {
                action.AddParameter("p1", new EdmEntityTypeReference(edmEntityType, false));
                action.AddParameter("p2", new EdmEntityTypeReference(edmEntityType, false));
            }

            var actionImport = container.AddActionImport("FakeAction", action, edmPathExpression);
          
            return actionImport.GetTargetEntitySet(sourceEntitySet, model);
        }
Exemplo n.º 17
0
        public static IEdmModel GetModelFunctionsOnNonEntityTypes()
        {
            EdmComplexType colorInfoType = new EdmComplexType("Test", "ColorInfo");
            colorInfoType.AddProperty(new EdmStructuralProperty(colorInfoType, "Red", EdmCoreModel.Instance.GetInt32(false)));
            colorInfoType.AddProperty(new EdmStructuralProperty(colorInfoType, "Green", EdmCoreModel.Instance.GetInt32(false)));
            colorInfoType.AddProperty(new EdmStructuralProperty(colorInfoType, "Blue", EdmCoreModel.Instance.GetInt32(false)));

            EdmEntityType vegetableType = new EdmEntityType("Test", "Vegetable");
            IEdmStructuralProperty id = vegetableType.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            vegetableType.AddKeys(id);
            vegetableType.AddStructuralProperty("Color", new EdmComplexTypeReference(colorInfoType, false));

            EdmEntityContainer container = new EdmEntityContainer("Test", "Container");
            var set = container.AddEntitySet("Vegetables", vegetableType);

            var function1 = new EdmFunction("Test", "IsPrime", EdmCoreModel.Instance.GetBoolean(false), true, null, true);
            function1.AddParameter("integer", EdmCoreModel.Instance.GetInt32(false));
            container.AddFunctionImport("IsPrime", function1);

            var action = new EdmAction("Test", "Subtract", EdmCoreModel.Instance.GetInt32(false), true /*isBound*/, null /*entitySetPath*/);
            action.AddParameter("integer", EdmCoreModel.Instance.GetInt32(false));
            container.AddActionImport(action);

            var function2 = new EdmFunction("Test", "IsDark", EdmCoreModel.Instance.GetBoolean(false), true, null, true);
            function2.AddParameter("color", new EdmComplexTypeReference(colorInfoType, false));
            container.AddFunctionImport("IsDark", function2);
            
            var function3 = new EdmFunction("Test", "IsDarkerThan", EdmCoreModel.Instance.GetBoolean(false), true, null, true);
            function3.AddParameter("color", new EdmComplexTypeReference(colorInfoType, false));
            function3.AddParameter("other", new EdmComplexTypeReference(colorInfoType, true));
            container.AddFunctionImport("IsDarkerThan", function3);

            var function4 = new EdmFunction("Test", "GetMostPopularVegetableWithThisColor", new EdmEntityTypeReference(vegetableType, true), true, new EdmPathExpression("color"), true);
            function4.AddParameter("color", new EdmComplexTypeReference(colorInfoType, false));
 
            EdmModel model = new EdmModel();
            model.AddElement(container);
            model.AddElement(vegetableType);
            model.AddElement(action);
            model.AddElement(function1);
            model.AddElement(function2);
            model.AddElement(function3);
            model.AddElement(function4);
            return model;
        }
Exemplo n.º 18
0
        public static IEdmModel GetModelWithMixedActionsAndFunctionsWithSameName()
        {
            EdmEntityType vegetableType = new EdmEntityType("Test", "Vegetable"); 
            IEdmStructuralProperty id = vegetableType.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            vegetableType.AddKeys(id);

            EdmEntityContainer container = new EdmEntityContainer("Test", "Container");
            var set = container.AddEntitySet("Vegetables", vegetableType);

            var action1 = new EdmAction("Test", "Foo", new EdmEntityTypeReference(vegetableType, true), false /*isBound*/, null /*entitySetPath*/);
            action1.AddParameter("p1", new EdmEntityTypeReference(vegetableType, false));
            container.AddActionImport("Foo", action1, new EdmEntitySetReferenceExpression(set));

            var function1 = new EdmFunction("Test", "Foo", new EdmEntityTypeReference(vegetableType, true), false /*isBound*/, null, true);
            function1.AddParameter("p1", new EdmEntityTypeReference(vegetableType, false));
            function1.AddParameter("p2", EdmCoreModel.Instance.GetInt32(false));
            container.AddFunctionImport("Foo", function1, new EdmEntitySetReferenceExpression(set));

            EdmModel model = new EdmModel();
            model.AddElement(container);
            model.AddElement(vegetableType);
            model.AddElement(action1);
            model.AddElement(function1);
            return model;
        }
Exemplo n.º 19
0
        public static EdmModel GetModelWithIllegalActionOverloads()
        {
            EdmEntityType vegetableType = new EdmEntityType("Test", "Vegetable");
            IEdmStructuralProperty id = vegetableType.AddStructuralProperty("ID", EdmCoreModel.Instance.GetInt32(false));
            vegetableType.AddKeys(id);

            EdmEntityContainer container = new EdmEntityContainer("Test", "Container");
            var set = container.AddEntitySet("Vegetables", vegetableType);
            
            var action1 = new EdmAction("Test", "Action", new EdmEntityTypeReference(vegetableType, true), true /*isBound*/, null /*entitySetPath*/);
            action1.AddParameter("p1", new EdmEntityTypeReference(vegetableType, false));
            container.AddActionImport("Action", action1, new EdmEntitySetReferenceExpression(set));
            
            var action2 = new EdmAction("Test", "Action", new EdmEntityTypeReference(vegetableType, true), true /*isBound*/, null /*entitySetPath*/);
            action2.AddParameter("p1", new EdmEntityTypeReference(vegetableType, false));
            action2.AddParameter("p2", EdmCoreModel.Instance.GetInt32(false));
            container.AddActionImport("Action", action2, new EdmEntitySetReferenceExpression(set));

            EdmModel model = new EdmModel();
            model.AddElement(container);
            model.AddElement(vegetableType);
            model.AddElement(action1);
            model.AddElement(action2);
            return model;
        }
Exemplo n.º 20
0
        public static TestModel Initialize()
        {
            EdmModel model = new EdmModel();
            var result = new TestModel(model);
            var productType = new EdmEntityType("TestModel", "Product");
            result.ProductType = productType;
            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);
            EdmEntityContainer defaultContainer = new EdmEntityContainer("TestModel", "Default");
            result.Container = defaultContainer;
            result.ProductsSet = defaultContainer.AddEntitySet("Products", productType);
            model.AddElement(defaultContainer);

            var derivedProductType = new EdmEntityType("TestModel", "DerivedProduct", productType);
            result.DerivedProductType = derivedProductType;

            EdmEntityType multipleKeyType = new EdmEntityType("TestModel", "MultipleKeyType");
            result.MultipleKeyType = multipleKeyType;
            EdmStructuralProperty keyAProperty = new EdmStructuralProperty(multipleKeyType, "KeyA", EdmCoreModel.Instance.GetString(false));
            EdmStructuralProperty keyBProperty = new EdmStructuralProperty(multipleKeyType, "KeyB", EdmCoreModel.Instance.GetInt32(false));
            multipleKeyType.AddProperty(keyAProperty);
            multipleKeyType.AddProperty(keyBProperty);
            multipleKeyType.AddKeys(keyAProperty, keyBProperty);
            model.AddElement(multipleKeyType);
            result.MultipleKeysSet = defaultContainer.AddEntitySet("MultipleKeySet", multipleKeyType);

            EdmEntityType productTypeWithNavProps = new EdmEntityType("TestModel", "ProductWithNavProps", productType);
            result.ProductWithNavPropsType = productTypeWithNavProps;
            productTypeWithNavProps.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
                {
                    Name = "RelatedProducts",
                    Target = productType,
                    TargetMultiplicity = EdmMultiplicity.Many
                });

            productTypeWithNavProps.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo()
            {
                Name = "RelatedDerivedProduct",
                Target = derivedProductType,
                TargetMultiplicity = EdmMultiplicity.One
            });

            model.AddElement(productTypeWithNavProps);

            EdmAction action = new EdmAction("TestModel", "SimpleAction", null/*returnType*/, true /*isBound*/, null /*entitySetPath*/);
            model.AddElement(action);
            defaultContainer.AddActionImport("SimpleAction", action);
            
            EdmAction action1 = new EdmAction("TestModel", "SimpleFunctionWithOverload", EdmCoreModel.Instance.GetInt32(false), true /*isbound*/, null);
            action1.AddParameter("p1", EdmCoreModel.Instance.GetInt32(false));
            defaultContainer.AddActionImport("SimpleFunctionWithOverload", action1);
            
            EdmAction action2 = new EdmAction("TestModel", "SimpleFunctionWithOverload", EdmCoreModel.Instance.GetInt32(false), true /*isbound*/, null);
            action2.AddParameter("p1", EdmCoreModel.Instance.GetString(false));
            defaultContainer.AddActionImport("SimpleFunctionWithOverload", action2);

            result.OneProductValue = BuildDefaultProductValue(productType);
            result.OneDerivedProductValue = BuildDefaultProductValue(derivedProductType);
            result.OneMultipleKeyValue = BuildDefaultMultipleKeyValue(model);
            result.OneProductWithNavPropsValue = BuildDefaultProductValue(productTypeWithNavProps);

            return result;
        }
        public CustomersModelWithInheritance()
        {
            EdmModel model = new EdmModel();

            // Enum type simpleEnum
            EdmEnumType simpleEnum = new EdmEnumType("NS", "SimpleEnum");
            simpleEnum.AddMember(new EdmEnumMember(simpleEnum, "First", new EdmIntegerConstant(0)));
            simpleEnum.AddMember(new EdmEnumMember(simpleEnum, "Second", new EdmIntegerConstant(1)));
            simpleEnum.AddMember(new EdmEnumMember(simpleEnum, "Third", new EdmIntegerConstant(2)));
            model.AddElement(simpleEnum);

            // complex type address
            EdmComplexType address = new EdmComplexType("NS", "Address");
            address.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
            address.AddStructuralProperty("City", EdmPrimitiveTypeKind.String);
            address.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
            address.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);
            address.AddStructuralProperty("Country", EdmPrimitiveTypeKind.String);
            model.AddElement(address);

            // entity type customer
            EdmEntityType customer = new EdmEntityType("NS", "Customer");
            customer.AddKeys(customer.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32));
            IEdmProperty customerName = customer.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            customer.AddStructuralProperty("SimpleEnum", simpleEnum.ToEdmTypeReference(isNullable: false));
            customer.AddStructuralProperty("Address", new EdmComplexTypeReference(address, isNullable: true));
            IEdmTypeReference primitiveTypeReference = EdmCoreModel.Instance.GetPrimitive(
                EdmPrimitiveTypeKind.String,
                isNullable: true);
            customer.AddStructuralProperty(
                "City",
                primitiveTypeReference,
                defaultValue: null,
                concurrencyMode: EdmConcurrencyMode.Fixed);
            model.AddElement(customer);

            // derived entity type special customer
            EdmEntityType specialCustomer = new EdmEntityType("NS", "SpecialCustomer", customer);
            specialCustomer.AddStructuralProperty("SpecialCustomerProperty", EdmPrimitiveTypeKind.Guid);
            model.AddElement(specialCustomer);

            // entity type order
            EdmEntityType order = new EdmEntityType("NS", "Order");
            order.AddKeys(order.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32));
            order.AddStructuralProperty("Amount", EdmPrimitiveTypeKind.Int32);
            model.AddElement(order);

            // derived entity type special order
            EdmEntityType specialOrder = new EdmEntityType("NS", "SpecialOrder", order);
            specialOrder.AddStructuralProperty("SpecialOrderProperty", EdmPrimitiveTypeKind.Guid);
            model.AddElement(specialOrder);

            // test entity
            EdmEntityType testEntity = new EdmEntityType("System.Web.OData.Query.Expressions", "TestEntity");
            testEntity.AddStructuralProperty("SampleProperty", EdmPrimitiveTypeKind.Binary);
            model.AddElement(testEntity);

            // entity sets
            EdmEntityContainer container = new EdmEntityContainer("NS", "ModelWithInheritance");
            model.AddElement(container);
            EdmEntitySet customers = container.AddEntitySet("Customers", customer);
            EdmEntitySet orders = container.AddEntitySet("Orders", order);

            // actions
            EdmAction upgrade = new EdmAction("NS", "upgrade", returnType: null, isBound: true, entitySetPathExpression: null);
            upgrade.AddParameter("entity", new EdmEntityTypeReference(customer, false));
            model.AddElement(upgrade);
            EdmActionImport upgradeCustomer = container.AddActionImport(
                "upgrade",
                upgrade,
                new EdmEntitySetReferenceExpression(customers));

            EdmAction specialUpgrade =
                new EdmAction("NS", "specialUpgrade", returnType: null, isBound: true, entitySetPathExpression: null);
            specialUpgrade.AddParameter("entity", new EdmEntityTypeReference(specialCustomer, false));
            model.AddElement(specialUpgrade);
            EdmActionImport upgradeSpecialCustomer = container.AddActionImport(
                "specialUpgrade",
                specialUpgrade,
                new EdmEntitySetReferenceExpression(customers));

            // functions
            IEdmTypeReference returnType = EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Boolean, isNullable: false);
            EdmFunction IsUpgraded = new EdmFunction(
                "NS",
                "IsUpgraded",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            IsUpgraded.AddParameter("entity", new EdmEntityTypeReference(customer, false));
            model.AddElement(IsUpgraded);
            EdmFunctionImport isCustomerUpgraded = container.AddFunctionImport(
                "IsUpgraded",
                IsUpgraded,
                new EdmEntitySetReferenceExpression(customers));

            EdmFunction IsSpecialUpgraded = new EdmFunction(
                "NS",
                "IsSpecialUpgraded",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            IsSpecialUpgraded.AddParameter("entity", new EdmEntityTypeReference(specialCustomer, false));
            model.AddElement(IsSpecialUpgraded);
            var isSpecialCustomerUpgraded = container.AddFunctionImport(
                "IsSpecialUpgraded",
                IsSpecialUpgraded,
                new EdmEntitySetReferenceExpression(customers));

            EdmFunction IsAnyUpgraded = new EdmFunction(
                "NS",
                "IsAnyUpgraded",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            EdmCollectionType edmCollectionType = new EdmCollectionType(new EdmEntityTypeReference(customer, false));
            IsAnyUpgraded.AddParameter("entityset", new EdmCollectionTypeReference(edmCollectionType));
            model.AddElement(IsAnyUpgraded);
            container.AddFunctionImport(
                "IsAnyUpgraded",
                IsAnyUpgraded,
                new EdmEntitySetReferenceExpression(customers));

            EdmFunction isCustomerUpgradedWithParam = new EdmFunction(
                "NS",
                "IsUpgradedWithParam",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            isCustomerUpgradedWithParam.AddParameter("entity", new EdmEntityTypeReference(customer, false));
            isCustomerUpgradedWithParam.AddParameter("city", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.String, isNullable: false));
            model.AddElement(isCustomerUpgradedWithParam);
            container.AddFunctionImport(
                "IsUpgradedWithParam",
                isCustomerUpgradedWithParam,
                new EdmEntitySetReferenceExpression(customers));

            EdmFunction isCustomerLocal = new EdmFunction(
                "NS",
                "IsLocal",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            isCustomerLocal.AddParameter("entity", new EdmEntityTypeReference(customer, false));
            model.AddElement(isCustomerLocal);
            container.AddFunctionImport(
                "IsLocal",
                isCustomerLocal,
                new EdmEntitySetReferenceExpression(customers));

            // navigation properties
            customers.AddNavigationTarget(
                customer.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
                {
                    Name = "Orders",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = order
                }),
                orders);
            orders.AddNavigationTarget(
                 order.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
                 {
                     Name = "Customer",
                     TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                     Target = customer
                 }),
                customers);

            // navigation properties on derived types.
            customers.AddNavigationTarget(
                specialCustomer.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
                {
                    Name = "SpecialOrders",
                    TargetMultiplicity = EdmMultiplicity.Many,
                    Target = order
                }),
                orders);
            orders.AddNavigationTarget(
                 specialOrder.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo
                 {
                     Name = "SpecialCustomer",
                     TargetMultiplicity = EdmMultiplicity.ZeroOrOne,
                     Target = customer
                 }),
                customers);
            model.SetAnnotationValue<BindableProcedureFinder>(model, new BindableProcedureFinder(model));

            // set properties
            Model = model;
            Container = container;
            Customer = customer;
            Order = order;
            Address = address;
            SpecialCustomer = specialCustomer;
            SpecialOrder = specialOrder;
            Orders = orders;
            Customers = customers;
            UpgradeCustomer = upgradeCustomer;
            UpgradeSpecialCustomer = upgradeSpecialCustomer;
            CustomerName = customerName;
            IsCustomerUpgraded = isCustomerUpgraded;
            IsSpecialCustomerUpgraded = isSpecialCustomerUpgraded;
        }
Exemplo n.º 22
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;
        }
        public ODataJsonLightWriterShortSpanIntegrationTests()
        {
            EdmModel tmpModel = new EdmModel();

            EdmComplexType complexType = new EdmComplexType("NS", "MyComplexType");
            EdmComplexTypeReference complexTypeReference = new EdmComplexTypeReference(complexType, isNullable: true);
            complexType.AddProperty(new EdmStructuralProperty(complexType, "StringProperty", EdmCoreModel.Instance.GetString(isNullable: true)));
            complexType.AddProperty(new EdmStructuralProperty(complexType, "ComplexProperty", complexTypeReference));

            EdmComplexType derivedComplexType = new EdmComplexType("NS", "MyDerivedComplexType", complexType, false);
            derivedComplexType.AddProperty(new EdmStructuralProperty(derivedComplexType, "DerivedStringProperty", EdmCoreModel.Instance.GetString(isNullable: true)));
            
            this.entityType = new EdmEntityType("NS", "MyEntityType", isAbstract: false, isOpen: true, baseType: null);
            this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "StreamProperty", EdmCoreModel.Instance.GetStream(isNullable: true)));
            this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "StringProperty", EdmCoreModel.Instance.GetString(isNullable: true)));
            this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "ComplexProperty", complexTypeReference));
            EdmCollectionTypeReference stringCollectionType = new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: false)));
            this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "PrimitiveCollectionProperty", stringCollectionType));
            EdmCollectionTypeReference nullableStringCollectionType = new EdmCollectionTypeReference(
                new EdmCollectionType(EdmCoreModel.Instance.GetString(isNullable: true)));
            this.entityType.AddProperty(new EdmStructuralProperty(
                this.entityType,
                "NullablePrimitiveCollectionProperty",
                nullableStringCollectionType));
            EdmCollectionTypeReference nullableIntCollectionType = new EdmCollectionTypeReference(
                new EdmCollectionType(EdmCoreModel.Instance.GetInt32(isNullable: true)));
            this.entityType.AddProperty(new EdmStructuralProperty(
                this.entityType,
                "NullableIntCollectionProperty",
                nullableIntCollectionType));
            EdmCollectionTypeReference complexCollectionType = new EdmCollectionTypeReference(new EdmCollectionType(complexTypeReference));
            this.entityType.AddProperty(new EdmStructuralProperty(this.entityType, "ComplexCollectionProperty", complexCollectionType));

            this.entityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "EntityReferenceProperty", Target = this.entityType, TargetMultiplicity = EdmMultiplicity.ZeroOrOne });
            this.entityType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "EntitySetReferenceProperty", Target = this.entityType, TargetMultiplicity = EdmMultiplicity.Many });

            this.derivedEntityType = new EdmEntityType("NS", "MyDerivedEntityType", isAbstract: false, isOpen: true, baseType: this.entityType);
            this.mleEntityType = new EdmEntityType("NS", "MyMleEntityType", isAbstract: false, isOpen: true, hasStream: true, baseType: this.derivedEntityType);

            tmpModel.AddElement(this.entityType);
            tmpModel.AddElement(this.derivedEntityType);
            tmpModel.AddElement(this.mleEntityType);
            tmpModel.AddElement(complexType);
            tmpModel.AddElement(derivedComplexType);

            var defaultContainer = new EdmEntityContainer("NS", "DefaultContainer_sub");
            tmpModel.AddElement(defaultContainer);

            this.entitySet = new EdmEntitySet(defaultContainer, "MySet", this.entityType);

            var entityTypeReference = new EdmEntityTypeReference(this.entityType, isNullable: false);

            EdmAction action = new EdmAction("NS", "Action1", null /*returnType*/, true /*isBound*/, null /*entitySetPath*/);
            action.AddParameter( "bindingParameter", entityTypeReference);
            tmpModel.AddElement(action);
            defaultContainer.AddActionImport("Action1", action);
            
            EdmFunction function = new EdmFunction("NS", "Action1", EdmCoreModel.Instance.GetInt32(true) /*returnType*/, true /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
            function.AddParameter("bindingParameter", entityTypeReference);
            tmpModel.AddElement(function);
            defaultContainer.AddFunctionImport("Function1", function);

            this.userModel = TestUtils.WrapReferencedModelsToMainModel("NS", "DefaultContainer", tmpModel);
        }
        public void CannotParseAmbiguousAction()
        {
            // Arrange
            EdmModel model = new EdmModel();
            EdmEntityContainer container = new EdmEntityContainer("NS", "Container");
            model.AddElement(container);

            container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));
            container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));

            // Act & Assert
            Assert.Throws<ODataException>(
                () => _parser.Parse(model, _serviceRoot, _serviceRoot + "AmbiguousAction"),
                "Multiple action import overloads were found with the same binding parameter for 'AmbiguousAction'.");
        }
Exemplo n.º 25
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;
        }
Exemplo n.º 26
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;
        }
Exemplo n.º 27
0
        private static IEdmEntityContainer GetEntityContainer()
        {
            var entityCollection = new EdmCollectionTypeReference(new EdmCollectionType(_entityType), isNullable: false);
            var derivedEntityCollection = new EdmCollectionTypeReference(new EdmCollectionType(_derivedEntityType), isNullable: false);
            EdmEntityContainer container = new EdmEntityContainer("NS", "Name");

            // non-bindable action
            container.AddActionImport(new EdmAction("NS", "NonBindableAction", returnType: null));

            // action bound to entity
            var actionBoundToEntity = new EdmAction(
                "NS",
                "ActionBoundToEntity",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToEntity.AddParameter("Param", _entityType);
            container.AddActionImport(actionBoundToEntity);

            // action bound to derived entity
            var actionBoundToDerivedEntity = new EdmAction(
                "NS",
                "ActionBoundToDerivedEntity",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToDerivedEntity.AddParameter("Param", _derivedEntityType);
            container.AddActionImport(actionBoundToDerivedEntity);

            // action bound to entity collection
            var actionBoundToEntityCollection = new EdmAction(
                "NS",
                "ActionBoundToEntityCollection",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToEntityCollection.AddParameter("Param", entityCollection);
            container.AddActionImport(actionBoundToEntityCollection);

            // action bound to derived entity collection
            var actionBoundToDerivedEntityCollection = new EdmAction(
                "NS",
                "ActionBoundToDerivedEntityCollection",
                returnType: null,
                isBound: true,
                entitySetPathExpression: null);
            actionBoundToDerivedEntityCollection.AddParameter("Param", derivedEntityCollection);
            container.AddActionImport(actionBoundToDerivedEntityCollection);

            // ambiguos actions
            container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));
            container.AddActionImport(new EdmAction("NS", "AmbiguousAction", returnType: null));

            IEdmTypeReference returnType = new EdmPrimitiveTypeReference(
                EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Int32), false);

            // non-bindable function
            container.AddFunctionImport(new EdmFunction("NS", "NonBindableFunction", returnType));

            // function bound to entity
            var functionBoundToEntity = new EdmFunction(
                "NS",
                "FunctionBoundToEntity",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToEntity.AddParameter("Param", _entityType);
            container.AddFunctionImport(functionBoundToEntity);

            // function bound to entity
            var functionBoundToDerivedEntity = new EdmFunction(
                "NS",
                "FunctionBoundToDerivedEntity",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToDerivedEntity.AddParameter("Param", _derivedEntityType);
            container.AddFunctionImport(functionBoundToDerivedEntity);

            // function bound to entity collection
            var functionBoundToEntityCollection = new EdmFunction(
                "NS",
                "FunctionBoundToEntityCollection",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToEntityCollection.AddParameter("Param", entityCollection);
            container.AddFunctionImport(functionBoundToEntityCollection);

            // function bound to derived entity collection
            var functionBoundToDerivedEntityCollection = new EdmFunction(
                "NS",
                "FunctionBoundToDerivedEntityCollection",
                returnType,
                isBound: true,
                entitySetPathExpression: null,
                isComposable: false);
            functionBoundToDerivedEntityCollection.AddParameter("Param", derivedEntityCollection);
            container.AddFunctionImport(functionBoundToDerivedEntityCollection);

            return container;
        }