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


C# IEdmModel.FindEntityContainer方法代码示例

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


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

示例1: ConvertInMemoryAnnotations

        /// <summary>
        /// Convert the in-memory annotations from the source schema to the target model.
        /// </summary>
        /// <param name="entityModelSchema">The source schema.</param>
        /// <param name="model">The target model.</param>
        /// <remarks>
        /// We have to do this as a separate step because the base converter goes through
        /// Xml to do the conversion.
        /// </remarks>
        private static void ConvertInMemoryAnnotations(EntityModelSchema entityModelSchema, IEdmModel model)
        {
            Debug.Assert(entityModelSchema != null, "entityModelSchema != null");
            Debug.Assert(model != null, "model != null");

            IEnumerable<EntityContainer> entityContainers = entityModelSchema.EntityContainers;
            if (entityContainers != null)
            {
                foreach (EntityContainer entityContainer in entityContainers)
                {
                    IEdmEntityContainer edmContainer = (IEdmEntityContainer)model.FindEntityContainer(entityContainer.Name);
                    Debug.Assert(edmContainer != null, "edmContainer != null");

                }
            }
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:25,代码来源:ODataQueryEntityModelSchemaToEdmModelConverter.cs

示例2: GetExpectedFunctionImport

            /// <summary>
            /// Returns the function import for a parameters payload.
            /// </summary>
            /// <param name="expectedTypeAnnotation">The expected type annotation.</param>
            /// <param name="model">The model to get the function import from.</param>
            /// <returns>Returns the function import for a parameters payload.</returns>
            private static IEdmOperationImport GetExpectedFunctionImport(ExpectedTypeODataPayloadElementAnnotation expectedTypeAnnotation, IEdmModel model)
            {
                ExceptionUtilities.Assert(model != null, "model != null");

                if (expectedTypeAnnotation != null)
                {
                    if (expectedTypeAnnotation.ProductFunctionImport != null)
                    {
                        return expectedTypeAnnotation.ProductFunctionImport;
                    }
                    FunctionImport functionImport = expectedTypeAnnotation.FunctionImport;
                    if (functionImport != null)
                    {
                        var container = model.FindEntityContainer(functionImport.Container.FullName);
                        var functionImports = container.FindOperationImports(functionImport.Name);
                        if (functionImports != null && functionImports.Any())
                        {
                            // Note that we don't support overload for Actions. Single() will throw if the model is invalid.
                            return functionImports.Single();
                        }
                    }
                }

                return null;
            }
开发者ID:larsenjo,项目名称:odata.net,代码行数:31,代码来源:PayloadReaderTestDescriptor.cs

示例3: CreateEdmTestDescriptors

        private IEnumerable<PayloadWriterTestDescriptor<ODataItem>> CreateEdmTestDescriptors(IEnumerable<ProjectedPropertiesTestCase> testCases, IEdmModel model)
        {
            EdmEntitySet entitySet = null;
            EdmEntitySet wrappingEntitySet = null;

            if (model != null)
            {
                var container = model.FindEntityContainer("DefaultContainer");
                entitySet = container.FindEntitySet("EntitySet") as EdmEntitySet;
                wrappingEntitySet = container.FindEntitySet("WrappingEntitySet") as EdmEntitySet;
 
            }
            
            return testCases.Select(testCase =>
            {
                var payload = this.CreatePayload(testCase);
                string typeName = ((ODataEntry)payload.First()).TypeName;

                EdmEntitySet containerSet;
                switch (typeName)
                {
                    case "TestModel.EntityType":
                        containerSet = entitySet;
                        break;
                    case "TestModel.WrappingEntityType":
                        containerSet = wrappingEntitySet;
                        break;
                    default:
                        throw new TaupoInvalidOperationException("Unexpected type name: " + typeName + ".");
                }

                return new PayloadWriterTestDescriptor<ODataItem>(
                    this.Settings,
                    payload,
                    (tc) => this.CreateExpectedResults(tc, testCase, /*withModel*/model != null))
                {
                    DebugDescription = testCase.DebugDescription + (model == null ? " (without model)" : " (with model)"),
                    Model = model,
                    PayloadEdmElementContainer = containerSet,
                    SkipTestConfiguration = tc =>
                        testCase.ResponseOnly && tc.IsRequest ||
                        (model == null && tc.Format == ODataFormat.Json) ||
                        (testCase.IgnoreFormats != null && testCase.IgnoreFormats.Contains(tc.Format))
                };
            });
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:46,代码来源:WriterProjectedPropertyTests.cs

示例4: ResolveEntityModelSchemaFunctionImport

        /// <summary>
        /// Resolves the specified entity model function import and returns the Edm model function import for it.
        /// </summary>
        /// <param name="model">The model to get the type from.</param>
        /// <param name="functionImport">The entity model function import to resolve.</param>
        /// <returns>The resolved function import for the specified <paramref name="functionImport"/>.</returns>
        public static IEdmOperationImport ResolveEntityModelSchemaFunctionImport(IEdmModel model, FunctionImport functionImport)
        {
            if (functionImport == null)
            {
                return null;
            }

            if (model == null)
            {
                return null;
            }

            IEdmEntityContainer edmEntityContainer = model.FindEntityContainer(functionImport.Container.FullName);
            if (edmEntityContainer == null)
            {
                ExceptionUtilities.Assert(
                    edmEntityContainer != null,
                    "The entity container '{0}' for function import '{1}' was not found in the model.",
                    functionImport.Container.FullName,
                    functionImport.Name);
            }

            IEnumerable<IEdmOperationImport> edmFunctionImports = edmEntityContainer.FindOperationImports(functionImport.Name);
            ExceptionUtilities.Assert(
                edmFunctionImports.Count() == 1,
                "There's either no or more than one function import with name '{0}' in the entity container '{1}'.",
                functionImport.Name,
                functionImport.Container.FullName);

            return edmFunctionImports.Single();
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:37,代码来源:EdmModelUtils.cs

示例5: TopFilterExpressionTestCases

        public static IEnumerable<FilterTestCase> TopFilterExpressionTestCases(IEdmModel model)
        {
            EntityRangeVariable entityRangeVariable = new EntityRangeVariable("dummy", model.ResolveTypeReference("TestNS.TypeWithPrimitiveProperties", false).AsEntity(), model.FindEntityContainer("BinderTestMetadata").FindEntitySet("TypesWithPrimitiveProperties"));
            yield return new FilterTestCase()
            {
                EntitySetName = "TypesWithPrimitiveProperties",
                Filter = "BoolProperty",
                ExpectedFilterCondition = new SingleValuePropertyAccessNode(
                 new EntityRangeVariableReferenceNode(entityRangeVariable.Name, entityRangeVariable),
                 model.ResolveProperty("TestNS.TypeWithPrimitiveProperties.BoolProperty")
             )
            };

            yield return new FilterTestCase()
            {
                EntitySetName = "TypesWithPrimitiveProperties",
                Filter = "NullableBoolProperty",
                ExpectedFilterCondition = new SingleValuePropertyAccessNode(
              new EntityRangeVariableReferenceNode(entityRangeVariable.Name, entityRangeVariable),
              model.ResolveProperty("TestNS.TypeWithPrimitiveProperties.NullableBoolProperty")
          )
            };
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:23,代码来源:FilterBinderFunctionalTests.cs

示例6: PropertyAccessTestCases

        public static IEnumerable<FilterTestCase> PropertyAccessTestCases(IEdmModel model)
        {
            // Accessing a primitive property on the entity type
            EntityRangeVariable customersEntityRangeVariable = new EntityRangeVariable("dummy", model.ResolveTypeReference("TestNS.Customer", false).AsEntity(), model.FindEntityContainer("BinderTestMetadata").FindEntitySet("Customers"));
            SingleValuePropertyAccessNode propertyAccessNode = new SingleValuePropertyAccessNode(new EntityRangeVariableReferenceNode(customersEntityRangeVariable.Name, customersEntityRangeVariable),
                        model.ResolveProperty("TestNS.Customer.Name"));
            yield return new FilterTestCase()
            {
                Filter = "Name eq 'Vitek'",
                ExpectedFilterCondition = new BinaryOperatorNode(BinaryOperatorKind.Equal, propertyAccessNode, new ConstantNode("Vitek"))
            };

            // Accessing a complex on entity and primitive on complex
            SingleValuePropertyAccessNode propertyAccessNode2 = new SingleValuePropertyAccessNode(
                new SingleValuePropertyAccessNode(
                    new EntityRangeVariableReferenceNode(customersEntityRangeVariable.Name, customersEntityRangeVariable),
                    model.ResolveProperty("TestNS.Customer.Address")
                    ),
                model.ResolveProperty("TestNS.Address.City")
                );
            yield return new FilterTestCase()
            {
                Filter = "Address/City ne 'Prague'",
                ExpectedFilterCondition = new BinaryOperatorNode(BinaryOperatorKind.NotEqual, propertyAccessNode2, new ConstantNode("Prague"))
            };
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:26,代码来源:FilterBinderFunctionalTests.cs

示例7: ToTestDescriptor

            public PayloadReaderTestDescriptor ToTestDescriptor(PayloadReaderTestDescriptor.Settings settings, IEdmModel model, bool withMetadataAnnotation = false)
            {
                IEdmEntityContainer container = model.FindEntityContainer("DefaultContainer");
                IEdmEntitySet citiesEntitySet = container.FindEntitySet("Cities");
                IEdmType cityType = model.FindType("TestModel.CityType");

                EntityInstance entity = PayloadBuilder.Entity("TestModel.CityType")
                    .ExpectedEntityType(cityType, citiesEntitySet)
                    .JsonRepresentation(
                        "{" +
                        (withMetadataAnnotation ? ("\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataContextAnnotationName + "\":\"http://http://odata.org/test/$metadata#DefaultContainer.Cities/$entity\",") : string.Empty) +
                            "\"" + JsonLightConstants.ODataPropertyAnnotationSeparator + JsonLightConstants.ODataTypeAnnotationName + "\":\"TestModel.CityType\"," +
                            this.Json +
                            ",\"Id\":1" +
                        "}");

                foreach (PropertyInstance property in this.ExpectedEntity.Properties)
                {
                    entity.Add(property.DeepCopy());
                }

                entity.Add(PayloadBuilder.PrimitiveProperty("Id", 1));

                return new NavigationLinkTestCaseDescriptor(settings)
                {
                    DebugDescription = this.DebugDescription,
                    PayloadElement = entity,
                    PayloadEdmModel = model,
                    ExpectedException = this.ExpectedException,
                    ExpectedIsCollectionValues = this.ExpectedIsCollectionValues,
                };
            }
开发者ID:larsenjo,项目名称:odata.net,代码行数:32,代码来源:NavigationLinkInRequestReaderJsonLightTests.cs


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