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


C# EdmModel.EntityContainer方法代码示例

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


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

示例1: NullValueNonPropertyErrorTests

        public void NullValueNonPropertyErrorTests()
        {
            EdmModel model = new EdmModel();
            var entityType = model.EntityType("OwningType", "TestModel").KeyProperty("ID", EdmCoreModel.Instance.GetInt32(false) as EdmTypeReference);
            model.EntityContainer("DefaultContainer");
            var entitySet = model.EntitySet("EntitySet", entityType);

            IEnumerable<PayloadReaderTestDescriptor> testDescriptors = new[]
            {
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    DebugDescription = "null collection - should fail.",
                    PayloadEdmModel = model,
                    PayloadElement = PayloadBuilder.PrimitiveCollection().ExpectedCollectionItemType(EdmDataTypes.Int32)
                        .JsonRepresentation(
                            "{" + 
                            "\"@odata.context\":\"http://odata.org/test/$metadata#Edm.Null\"" +
                            "}"),
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightContextUriParser_ContextUriDoesNotMatchExpectedPayloadKind", "http://odata.org/test/$metadata#Edm.Null", "Collection")
                },
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    DebugDescription = "null entry - should fail.",
                    PayloadEdmModel = model,
                    PayloadElement = PayloadBuilder.NullEntity().ExpectedEntityType(entityType, entitySet)
                        .JsonRepresentation(
                            "{" + 
                            "\"@odata.context\":\"http://odata.org/test/$metadata#Edm.Null\"" +
                            "}"),
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightContextUriParser_ContextUriDoesNotMatchExpectedPayloadKind", "http://odata.org/test/$metadata#Edm.Null", "Entry")
                },
                new PayloadReaderTestDescriptor(this.Settings)
                {
                    DebugDescription = "null feed - should fail.",
                    PayloadEdmModel = model,
                    PayloadElement = PayloadBuilder.EntitySet().ExpectedEntityType(entityType, entitySet)
                        .JsonRepresentation(
                            "{" + 
                            "\"@odata.context\":\"http://odata.org/test/$metadata#Edm.Null\"" +
                            "}"),
                    ExpectedException = ODataExpectedExceptions.ODataException("ODataJsonLightContextUriParser_ContextUriDoesNotMatchExpectedPayloadKind", "http://odata.org/test/$metadata#Edm.Null", "Feed")
                },
            };

            this.CombinatorialEngineProvider.RunCombinations(
                testDescriptors,
                this.ReaderTestConfigurationProvider.JsonLightFormatConfigurations,
                (testDescriptor, testConfiguration) =>
                {
                    if (testConfiguration.IsRequest)
                    {
                        return;
                    }

                    // These descriptors are already tailored specifically for Json Light and 
                    // do not require normalization.
                    testDescriptor.TestDescriptorNormalizers.Clear();
                    testDescriptor.RunTest(testConfiguration);
                });
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:60,代码来源:NullValueTests.cs

示例2: ActionAndFunctionTest

        public void ActionAndFunctionTest()
        {
            // <m:action Metadata=URI title?="title" target=URI />

            Uri actionMetadata = new Uri("http://odata.org/test/$metadata#defaultAction");
            Uri actionMetadata2 = new Uri("#action escaped relative metadata", UriKind.Relative);
            Uri actionMetadata3 = new Uri("../#action escaped relative metadata", UriKind.Relative);
            string actionTitle = "Default Action";
            Uri actionTarget = new Uri("http://odata.org/defaultActionTarget");
            Uri actionTarget2 = new Uri("http://odata.org/defaultActionTarget2");

            ODataAction action_r1_t1 = new ODataAction() { Metadata = actionMetadata, Title = actionTitle, Target = actionTarget };
            ODataAction action_r1_t2 = new ODataAction() { Metadata = actionMetadata, Title = actionTitle, Target = actionTarget2 };
            ODataAction action_r2_t1 = new ODataAction() { Metadata = actionMetadata2, Title = actionTitle, Target = actionTarget };
            ODataAction action_r3_t1 = new ODataAction() { Metadata = actionMetadata3, Title = actionTitle, Target = actionTarget };

            Uri functionMetadata = new Uri("http://odata.org/test/$metadata#defaultFunction");
            Uri functionMetadata2 = new Uri("#function escaped relative metadata", UriKind.Relative);
            Uri functionMetadata3 = new Uri("\\#function escaped relative metadata", UriKind.Relative);
            string functionTitle = "Default Function";
            Uri functionTarget = new Uri("http://odata.org/defaultFunctionTarget");
            Uri functionTarget2 = new Uri("http://odata.org/defaultFunctionTarget2");

            ODataFunction function_r1_t1 = new ODataFunction() { Metadata = functionMetadata, Title = functionTitle, Target = functionTarget };
            ODataFunction function_r1_t2 = new ODataFunction() { Metadata = functionMetadata, Title = functionTitle, Target = functionTarget2 };
            ODataFunction function_r2_t1 = new ODataFunction() { Metadata = functionMetadata2, Title = functionTitle, Target = functionTarget };
            ODataFunction function_r3_t1 = new ODataFunction() { Metadata = functionMetadata3, Title = functionTitle, Target = functionTarget };

            var actionCases = new[]
            {
                new {
                    ODataActions = new ODataAction[] { action_r1_t1 },
                    Atom = GetAtom(action_r1_t1),
                    JsonLight = GetJsonLightForRelGroup(action_r1_t1),
                },
                new {
                    ODataActions = new ODataAction[] { action_r1_t1, action_r1_t2 },
                    Atom = GetAtom(action_r1_t1) + GetAtom(action_r1_t2),
                    JsonLight = GetJsonLightForRelGroup(action_r1_t1, action_r1_t2),
                },
                new {
                    ODataActions = new ODataAction[] { action_r1_t1, action_r2_t1 },
                    Atom = GetAtom(action_r1_t1) + GetAtom(action_r2_t1),
                    JsonLight = GetJsonLightForRelGroup(action_r1_t1) + "," + GetJsonLightForRelGroup(action_r2_t1),
                },
                new {
                    ODataActions = new ODataAction[] { action_r1_t1, action_r2_t1, action_r1_t2 },
                    Atom = GetAtom(action_r1_t1) + GetAtom(action_r2_t1) + GetAtom(action_r1_t2),
                    JsonLight = GetJsonLightForRelGroup(action_r1_t1, action_r1_t2) + "," + GetJsonLightForRelGroup(action_r2_t1),
                },
                new {
                    ODataActions = new ODataAction[] { action_r3_t1 },
                    Atom = GetAtom(action_r3_t1),
                    JsonLight = GetJsonLightForRelGroup(action_r3_t1),
                },
            };

            var functionCases = new[]
            {
                new {
                    ODataFunctions = new ODataFunction[] { function_r1_t1 },
                    Atom = GetAtom(function_r1_t1),
                    JsonLight = GetJsonLightForRelGroup(function_r1_t1),
                },
                new {
                    ODataFunctions = new ODataFunction[] { function_r1_t1, function_r1_t2 },
                    Atom = GetAtom(function_r1_t1) + GetAtom(function_r1_t2),
                    JsonLight = GetJsonLightForRelGroup(function_r1_t1, function_r1_t2),
                },
                new {
                    ODataFunctions = new ODataFunction[] { function_r1_t1, function_r2_t1 },
                    Atom = GetAtom(function_r1_t1) + GetAtom(function_r2_t1),
                    JsonLight = GetJsonLightForRelGroup(function_r1_t1) + "," + GetJsonLightForRelGroup(function_r2_t1),
                },
                new {
                    ODataFunctions = new ODataFunction[] { function_r1_t1, function_r2_t1, function_r1_t2 },
                    Atom = GetAtom(function_r1_t1) + GetAtom(function_r2_t1) + GetAtom(function_r1_t2),
                    JsonLight = GetJsonLightForRelGroup(function_r1_t1, function_r1_t2) + "," + GetJsonLightForRelGroup(function_r2_t1),
                },
                new {
                    ODataFunctions = new ODataFunction[] { function_r3_t1 },
                    Atom = GetAtom(function_r3_t1),
                    JsonLight = GetJsonLightForRelGroup(function_r3_t1),
                },
            };

            var queryResults =
                from actionCase in actionCases
                from functionCase in functionCases
                select new
                {
                    actionCase.ODataActions,
                    functionCase.ODataFunctions,
                    Atom = string.Concat(actionCase.Atom, functionCase.Atom),
                    JsonLight = string.Join(",", new[] { actionCase.JsonLight, functionCase.JsonLight }.Where(x => x != null))
                };

            EdmModel model = new EdmModel();
            EdmEntityType edmEntityTypeCustomer = model.EntityType("Customer", "TestModel");
            EdmEntityContainer edmEntityContainer = model.EntityContainer("DefaultContainer","TestModel" );
//.........这里部分代码省略.........
开发者ID:AlineGuan,项目名称:odata.net,代码行数:101,代码来源:WriterActionAndFunctionTests.cs


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