当前位置: 首页>>代码示例>>C#>>正文


C# EdmComplexType.AddStructuralProperty方法代码示例

本文整理汇总了C#中Microsoft.OData.Edm.Library.EdmComplexType.AddStructuralProperty方法的典型用法代码示例。如果您正苦于以下问题:C# EdmComplexType.AddStructuralProperty方法的具体用法?C# EdmComplexType.AddStructuralProperty怎么用?C# EdmComplexType.AddStructuralProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.OData.Edm.Library.EdmComplexType的用法示例。


在下文中一共展示了EdmComplexType.AddStructuralProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: NonPrimitiveTypeRoundtripAtomTests

        public NonPrimitiveTypeRoundtripAtomTests()
        {
            this.model = new EdmModel();

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

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

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

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

            model.AddElement(studentInfo);
            model.AddElement(personalInfo);
            model.AddElement(subjectInfo);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:27,代码来源:NonPrimitiveTypeRoundtripAtomTests.cs

示例2: ComplexValueTest

        public void ComplexValueTest()
        {
            EdmModel model = new EdmModel();

            var emptyComplexType = new EdmComplexType(DefaultNamespaceName, "EmptyComplexType");
            model.AddElement(emptyComplexType);

            var complexTypeWithStringProperty = new EdmComplexType(DefaultNamespaceName, "ComplexTypeWithStringProperty");
            complexTypeWithStringProperty.AddStructuralProperty("stringProperty", EdmCoreModel.Instance.GetString(isNullable: true));
            complexTypeWithStringProperty.AddStructuralProperty("numberProperty", EdmCoreModel.Instance.GetInt32(isNullable: false));
            model.AddElement(complexTypeWithStringProperty);

            model.Fixup();
            

            IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new[]
            {
                // Empty element is a valid complex value
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    PayloadElement = PayloadBuilder.ComplexValue("TestModel.EmptyComplexType")
                        .XmlValueRepresentation(new XNode[0])
                        .WithTypeAnnotation(emptyComplexType),
                    PayloadEdmModel = model
                },
            };

            testDescriptors = testDescriptors.Concat(
                PropertiesElementAtomValues.CreatePropertiesElementPaddingPayloads<ComplexInstance>(
                    new PayloadReaderTestDescriptor(this.Settings)
                    {
                        PayloadElement = PayloadBuilder.ComplexValue("TestModel.ComplexTypeWithStringProperty")
                            .WithTypeAnnotation(complexTypeWithStringProperty),
                        PayloadEdmModel = model
                    },
                    (complexInstance, xmlValue) => complexInstance.XmlValueRepresentation(xmlValue)));

            testDescriptors = testDescriptors.Select(td => td.InProperty());

            testDescriptors = testDescriptors.Concat(new []
            {
                // Top-level property without expected type and no type name - this is read as primitive string!
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    PayloadElement = PayloadBuilder.Property(null, PayloadBuilder.PrimitiveValue(string.Empty))
                        .XmlRepresentation("<m:value/>"),
                    PayloadEdmModel = model,
                },
            });

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.AtomFormatConfigurations,
                (testDescriptor, testConfiguration) =>
                {
                    testDescriptor.RunTest(testConfiguration);
                });
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:58,代码来源:ComplexValueReaderAtomTests.cs

示例3: Initialize

        public void Initialize()
        {
            this.model = new EdmModel();

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

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

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

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

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

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

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

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

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

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

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

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

            this.studentSet = new EdmEntitySet(defaultContainer, "MySet", this.studentInfo);
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:56,代码来源:NonPrimitiveTypeRoundtripJsonLightTests.cs

示例4: SimpleCustomerOrderModel

        public static IEdmModel SimpleCustomerOrderModel()
        {
            var model = new EdmModel();
            var customerType = new EdmEntityType("Default", "Customer");
            customerType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
            customerType.AddStructuralProperty("FirstName", EdmPrimitiveTypeKind.String);
            customerType.AddStructuralProperty("LastName", EdmPrimitiveTypeKind.String);
            IEdmTypeReference primitiveTypeReference = EdmCoreModel.Instance.GetPrimitive(
                EdmPrimitiveTypeKind.String,
                isNullable: true);
            customerType.AddStructuralProperty(
                "City",
                primitiveTypeReference,
                defaultValue: null,
                concurrencyMode: EdmConcurrencyMode.Fixed);
            model.AddElement(customerType);

            var orderType = new EdmEntityType("Default", "Order");
            orderType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32);
            orderType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            orderType.AddStructuralProperty("Shipment", EdmPrimitiveTypeKind.String);
            model.AddElement(orderType);

            var addressType = new EdmComplexType("Default", "Address");
            addressType.AddStructuralProperty("Street", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("City", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("State", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("Country", EdmPrimitiveTypeKind.String);
            addressType.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);
            model.AddElement(addressType);

            // Add navigations
            customerType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Orders", Target = orderType, TargetMultiplicity = EdmMultiplicity.Many });
            orderType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo() { Name = "Customer", Target = customerType, TargetMultiplicity = EdmMultiplicity.One });

            // Add Entity set
            var container = new EdmEntityContainer("Default", "Container");
            var customerSet = container.AddEntitySet("Customers", customerType);
            var orderSet = container.AddEntitySet("Orders", orderType);
            customerSet.AddNavigationTarget(customerType.NavigationProperties().Single(np => np.Name == "Orders"), orderSet);
            orderSet.AddNavigationTarget(orderType.NavigationProperties().Single(np => np.Name == "Customer"), customerSet);

            NavigationSourceLinkBuilderAnnotation linkAnnotation = new MockNavigationSourceLinkBuilderAnnotation();
            model.SetNavigationSourceLinkBuilder(customerSet, linkAnnotation);
            model.SetNavigationSourceLinkBuilder(orderSet, linkAnnotation);

            model.AddElement(container);
            return model;
        }
开发者ID:nicholaspei,项目名称:aspnetwebstack,代码行数:49,代码来源:SerializationTestsHelpers.cs

示例5: Initialize

        public void Initialize()
        {
            var addressEdmType = new EdmComplexType("Default", "Address");
            addressEdmType.AddStructuralProperty("ZipCode", EdmPrimitiveTypeKind.String);

            this.edmAddressComplexTypeRef = new EdmComplexTypeReference(addressEdmType, true);
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:7,代码来源:MaterializationPolicyUnitTests.cs

示例6: ReferentialConstraintDemo

        private static void ReferentialConstraintDemo()
        {
            Console.WriteLine("ReferentialConstraintDemo");

            EdmModel model = new EdmModel();
            var customer = new EdmEntityType("ns", "Customer");
            model.AddElement(customer);
            var customerId = customer.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false);
            customer.AddKeys(customerId);
            var address = new EdmComplexType("ns", "Address");
            model.AddElement(address);
            var code = address.AddStructuralProperty("gid", EdmPrimitiveTypeKind.Guid);
            customer.AddStructuralProperty("addr", new EdmComplexTypeReference(address, true));

            var order = new EdmEntityType("ns", "Order");
            model.AddElement(order);
            var oId = order.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false);
            order.AddKeys(oId);

            var orderCustomerId = order.AddStructuralProperty("CustomerId", EdmPrimitiveTypeKind.Int32, false);

            var nav = new EdmNavigationPropertyInfo()
            {
                Name = "NavCustomer",
                Target = customer,
                TargetMultiplicity = EdmMultiplicity.One,
                DependentProperties = new[] { orderCustomerId },
                PrincipalProperties = new[] { customerId }
            };
            order.AddUnidirectionalNavigation(nav);

            ShowModel(model);
        }
开发者ID:steveeliot81,项目名称:ODataSamples,代码行数:33,代码来源:Program.cs

示例7: MultipleSchemasWithDifferentNamespacesEdm

        public static IEdmModel MultipleSchemasWithDifferentNamespacesEdm()
        {
            var namespaces = new string[] 
                { 
                    "FindMethodsTestModelBuilder.MultipleSchemasWithDifferentNamespaces.first", 
                    "FindMethodsTestModelBuilder.MultipleSchemasWithDifferentNamespaces.second" 
                };

            var model = new EdmModel();
            foreach (var namespaceName in namespaces)
            {
                var entityType1 = new EdmEntityType(namespaceName, "validEntityType1");
                entityType1.AddKeys(entityType1.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
                var entityType2 = new EdmEntityType(namespaceName, "VALIDeNTITYtYPE2");
                entityType2.AddKeys(entityType2.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));
                var entityType3 = new EdmEntityType(namespaceName, "VALIDeNTITYtYPE3");
                entityType3.AddKeys(entityType3.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32));

                entityType1.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo {Name = "Mumble", Target = entityType2, TargetMultiplicity = EdmMultiplicity.Many});

                var complexType = new EdmComplexType(namespaceName, "ValidNameComplexType1");
                complexType.AddStructuralProperty("aPropertyOne", new EdmComplexTypeReference(complexType, false));
                model.AddElements(new IEdmSchemaElement[] { entityType1, entityType2, entityType3, complexType });

                var function1 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false)); 
                var function2 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
                function2.AddParameter("param1", new EdmEntityTypeReference(entityType1, false));
                var function3 = new EdmFunction(namespaceName, "ValidFunction1", EdmCoreModel.Instance.GetSingle(false));
                function3.AddParameter("param1", EdmCoreModel.Instance.GetSingle(false));

                model.AddElements(new IEdmSchemaElement[] {function1, function2, function3});
            }

            return model;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:35,代码来源:FindMethodsTestModelBuilder.cs

示例8: ODataAtomPropertyAndValueDeserializerTests

 static ODataAtomPropertyAndValueDeserializerTests()
 {
     EdmModel = new EdmModel();
     ComplexType = new EdmComplexType("TestNamespace", "TestComplexType");
     StringProperty = ComplexType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
     EdmModel.AddElement(ComplexType);
 }
开发者ID:rossjempson,项目名称:odata.net,代码行数:7,代码来源:ODataAtomPropertyAndValueDeserializerTests.cs

示例9: GetTmpType

        private IEdmType GetTmpType(IEdmOperation operation)
        {
            EdmComplexType type = new EdmComplexType(operation.Namespace, operation.Name + AvroConstants.ParameterTypeSuffix);

            foreach (var parameter in operation.Parameters.Skip(operation.IsBound ? 1 : 0))
            {
                type.AddStructuralProperty(parameter.Name, parameter.Type);
            }

            return type;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:11,代码来源:ODataAvroParameterWriter.cs

示例10: XElementAnnotationTestXElementWithWithoutNamespaceCsdl

        public void XElementAnnotationTestXElementWithWithoutNamespaceCsdl()
        {
            EdmModel model = new EdmModel();

            EdmComplexType complexType = new EdmComplexType("DefaultNamespace", "ComplexType");
            complexType.AddStructuralProperty("Data", EdmCoreModel.Instance.GetString(true));
            model.AddElement(complexType);

            XElement annotationElement = new XElement("EmptyAnnotation");
            var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString());
            VerifyThrowsException(typeof(InvalidOperationException), () => annotation.SetIsSerializedAsElement(model, true));
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:XElementAnnotationTest.cs

示例11: ODataAvroWriterTests

        static ODataAvroWriterTests()
        {
            var type = new EdmEntityType("NS", "SimpleEntry");
            type.AddStructuralProperty("TBoolean", EdmPrimitiveTypeKind.Boolean, true);
            type.AddStructuralProperty("TInt32", EdmPrimitiveTypeKind.Int32, true);
            type.AddStructuralProperty("TCollection", new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt64(false))));
            var cpx = new EdmComplexType("NS", "SimpleComplex");
            cpx.AddStructuralProperty("TBinary", EdmPrimitiveTypeKind.Binary, true);
            cpx.AddStructuralProperty("TString", EdmPrimitiveTypeKind.String, true);
            type.AddStructuralProperty("TComplex", new EdmComplexTypeReference(cpx, true));
            TestEntityType = type;

            binary0 = new byte[] { 4, 7 };
            complexValue0 = new ODataComplexValue()
            {
                Properties = new[]
                {
                    new ODataProperty {Name = "TBinary", Value = binary0 ,},
                    new ODataProperty {Name = "TString", Value = "iamstr",},
                },
                TypeName = "NS.SimpleComplex"
            };

            longCollection0 = new[] {7L, 9L};
            var collectionValue0 = new ODataCollectionValue { Items = longCollection0 };

            entry0 = new ODataEntry
            {
                Properties = new[]
                {
                    new ODataProperty {Name = "TBoolean", Value = true,},
                    new ODataProperty {Name = "TInt32", Value = 32,},
                    new ODataProperty {Name = "TComplex", Value = complexValue0,},
                    new ODataProperty {Name = "TCollection", Value = collectionValue0 },
                },
                TypeName = "NS.SimpleEntry"
            };
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:38,代码来源:ODataAvroWriterTests.cs

示例12: AnnotationWithoutChildrenModel

        public static EdmModel AnnotationWithoutChildrenModel()
        {
            EdmModel model = new EdmModel();

            EdmComplexType complexType = new EdmComplexType("DefaultNamespace", "ComplexType");
            complexType.AddStructuralProperty("Data", EdmCoreModel.Instance.GetString(true));
            model.AddElement(complexType);

            XElement annotationElement = new XElement("{http://foo}Annotation");
            var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString());
            annotation.SetIsSerializedAsElement(model, true);
            model.SetAnnotationValue(complexType, "http://foo", "Annotation", annotation);

            return model;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:XElementAnnotationModelBuilder.cs

示例13: JsonLightTypeResolverTests

        public JsonLightTypeResolverTests()
        {
            this.serverModel = new EdmModel();
            var serverEntityType = new EdmEntityType("Server.Name.Space", "EntityType");
            serverEntityType.AddKeys(serverEntityType.AddStructuralProperty("ID", EdmPrimitiveTypeKind.Int32));
            var parentType = new EdmEntityType("Server.Name.Space", "Parent");
            this.serverModel.AddElement(serverEntityType);
            this.serverModel.AddElement(parentType);

            var serverComplexType = new EdmComplexType("Server.Name.Space", "ComplexType");
            serverComplexType.AddStructuralProperty("Number", EdmPrimitiveTypeKind.Int32);
            this.serverModel.AddElement(serverComplexType);
            var entityContainer = new EdmEntityContainer("Fake", "Container");
            this.serverModel.AddElement(entityContainer);
            entityContainer.AddEntitySet("Entities", serverEntityType);
            entityContainer.AddEntitySet("Parents", parentType);

            parentType.AddUnidirectionalNavigation(new EdmNavigationPropertyInfo { Name = "Navigation", Target = serverEntityType, TargetMultiplicity = EdmMultiplicity.Many });
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:19,代码来源:JsonLightTypeResolverTests.cs

示例14: HeterogeneousCollectionReaderTest

        public void HeterogeneousCollectionReaderTest()
        {
            EdmModel model = new EdmModel();
            var cityType = new EdmComplexType("TestModel", "CityType");
            cityType.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(true));
            model.AddElement(cityType);

            var addressType = new EdmComplexType("TestModel", "AddressType");
            addressType.AddStructuralProperty("Street", EdmCoreModel.Instance.GetString(true));
            model.AddElement(addressType);

            var testContainer = new EdmEntityContainer("TestModel", "TestContainer");
            model.AddElement(testContainer);
            EdmFunction citiesFunction = new EdmFunction("TestModel", "Cities", EdmCoreModel.GetCollection(cityType.ToTypeReference()));
            model.AddElement(citiesFunction);
            EdmOperationImport citiesFunctionImport = testContainer.AddFunctionImport("Cities", citiesFunction);
            model.Fixup();
            
            // Add some hand-crafted payloads
            IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new PayloadReaderTestDescriptor[]
            {
                // expected type without type names in the payload and heterogeneous items
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    PayloadElement = new ComplexInstanceCollection(
                        PayloadBuilder.ComplexValue().Property("Name", PayloadBuilder.PrimitiveValue("Vienna")),
                        PayloadBuilder.ComplexValue().Property("Street", PayloadBuilder.PrimitiveValue("Am Euro Platz")))
                        .ExpectedFunctionImport(citiesFunctionImport)
                        .CollectionName(null),
                    PayloadEdmModel = model,
                    ExpectedException = ODataExpectedExceptions.ODataException("ValidationUtils_PropertyDoesNotExistOnType", "Street", "TestModel.CityType"),
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.ExplicitFormatConfigurations,
                (testDescriptor, testConfiguration) =>
                {
                    testDescriptor.RunTest(testConfiguration);
                });
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:42,代码来源:CollectionReaderTests.cs

示例15: NestedXElementWithNoValueModel

        public static EdmModel NestedXElementWithNoValueModel()
        {
            EdmModel model = new EdmModel();

            EdmComplexType simpleType = new EdmComplexType("DefaultNamespace", "SimpleType");
            EdmStructuralProperty simpleTypeId = simpleType.AddStructuralProperty("Id", EdmCoreModel.Instance.GetInt32(true));
            model.AddElement(simpleType);

            XElement annotationElement = 
                new XElement("{http://foo}Annotation",
                    new XElement("{http://foo}Child",
                        new XElement("{http://foo}GrandChild",
                            new XElement("{http://foo}GreatGrandChild",
                                new XElement("{http://foo}GreateGreatGrandChild")
                            )
                        )
                    )
                );
            var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString());
            annotation.SetIsSerializedAsElement(model, true);
            model.SetAnnotationValue(simpleTypeId, "http://foo", "Annotation", annotation);

            return model;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:24,代码来源:XElementAnnotationModelBuilder.cs


注:本文中的Microsoft.OData.Edm.Library.EdmComplexType.AddStructuralProperty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。