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


C# IEdmModel.EntityContainers方法代码示例

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


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

示例1: ODataQueryContext

        /// <summary>
        /// Constructs an instance of <see cref="ODataQueryContext"/> with EdmModel and Entity's CLR type. 
        /// By default we assume the full name of the CLR type is used for the name for the EntitySet stored in the model.
        /// </summary>
        /// <param name="model">The EdmModel that includes the Entity and EntitySet information.</param>
        /// <param name="entityClrType">The entity's CLR type information.</param>
        public ODataQueryContext(IEdmModel model, Type entityClrType)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

            if (entityClrType == null)
            {
                throw Error.ArgumentNull("entityClrType");
            }

            // check if we can successfully retrieve an entitySet from the model with the given entityClrType
            IEnumerable<IEdmEntityContainer> containers = model.EntityContainers();
            List<IEdmEntitySet> entities = new List<IEdmEntitySet>();
            foreach (IEdmEntityContainer container in containers)
            {
                entities.AddRange(container.EntitySets().Where(s => s.ElementType.IsEquivalentTo(model.GetEdmType(entityClrType))));
            }

            if (entities == null || entities.Count == 0)
            {
                throw Error.InvalidOperation(SRResources.EntitySetNotFound, entityClrType.FullName);
            }

            if (entities.Count > 1)
            {
                throw Error.InvalidOperation(SRResources.MultipleEntitySetMatchedClrType, entityClrType.FullName);
            }

            Model = model;
            EntityClrType = entityClrType;
            EntitySet = entities[0];
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:40,代码来源:ODataQueryContext.cs

示例2: UnboundFunctionPathSegmentTest

 public UnboundFunctionPathSegmentTest()
 {
     ODataModelBuilder builder = new ODataModelBuilder();
     builder.EntityType<MyCustomer>().HasKey(c => c.Id).Property(c => c.Name);
     builder.EntitySet<MyCustomer>("Customers");
     FunctionConfiguration function = builder.Function("TopCustomer");
     function.ReturnsFromEntitySet<MyCustomer>("Customers");
     builder.Function("MyFunction").Returns<string>();
     _model = builder.GetEdmModel();
     _container = _model.EntityContainers().Single();
 }
开发者ID:rfolkes,项目名称:aspnetwebstack,代码行数:11,代码来源:UnboundFunctionPathSegmentTest.cs

示例3: UnboundActionPathSegmentTest

 public UnboundActionPathSegmentTest()
 {
     ODataModelBuilder builder = new ODataModelBuilder();
     builder.Entity<MyCustomer>().HasKey(c => c.Id).Property(c => c.Name);
     builder.EntitySet<MyCustomer>("Customers");
     ActionConfiguration action = builder.Action("CreateCustomer");
     action.ReturnsFromEntitySet<MyCustomer>("Customers");
     builder.Action("MyAction").Returns<string>();
     builder.Action("ActionWithoutReturn");
     _model = builder.GetEdmModel();
     _container = _model.EntityContainers().Single();
 }
开发者ID:modulexcite,项目名称:aspnetwebstack-1,代码行数:12,代码来源:UnboundActionPathSegmentTest.cs

示例4: ODataEntityDeserializerTests

 public ODataEntityDeserializerTests()
 {
     _edmModel = EdmTestHelpers.GetModel();
     IEdmEntitySet entitySet = _edmModel.EntityContainers().Single().FindEntitySet("Products");
     _readContext = new ODataDeserializerContext
     {
         Path = new ODataPath(new EntitySetPathSegment(entitySet)),
         Model = _edmModel
     };
     _productEdmType = _edmModel.GetEdmTypeReference(typeof(Product)).AsEntity();
     _supplierEdmType = _edmModel.GetEdmTypeReference(typeof(Supplier)).AsEntity();
     _deserializerProvider = new DefaultODataDeserializerProvider();
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:13,代码来源:ODataEntityDeserializerTests.cs

示例5: BindableProcedureFinder

        /// <summary>
        /// Constructs a concurrent cache for looking up bindable procedures for any EntityType in the provided model.
        /// </summary>
        public BindableProcedureFinder(IEdmModel model)
        {
            var query =
                from ec in model.EntityContainers()
                from fi in ec.FunctionImports()
                where fi.IsBindable && fi.Parameters.First().Type.TypeKind() == EdmTypeKind.Entity
                group fi by fi.Parameters.First().Type.Definition into fgroup
                select new { EntityType = fgroup.Key as IEdmEntityType, BindableFunctions = fgroup.ToList() };

            foreach (var match in query)
            {
                _map[match.EntityType] = match.BindableFunctions;
            }
        }
开发者ID:AndreGleichner,项目名称:aspnetwebstack,代码行数:17,代码来源:BindableProcedureFinder.cs

示例6: ODataPathParser

        /// <summary>
        /// Initializes a new instance of the <see cref="ODataPathParser" /> class.
        /// </summary>
        /// <param name="model">The model to use for segment parsing.</param>
        public ODataPathParser(IEdmModel model)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

            IEnumerable<IEdmEntityContainer> containers = model.EntityContainers();
            int containerCount = containers.Count();
            if (containerCount != 1)
            {
                throw Error.InvalidOperation(SRResources.ParserModelMustHaveOneContainer, containerCount);
            }
            Model = model;
            Container = containers.Single();
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:20,代码来源:ODataPathParser.cs

示例7: GetNavigationProperty

 private static IEdmNavigationProperty GetNavigationProperty(IEdmModel model)
 {
     return
         model.EntityContainers().Single().EntitySets().First().NavigationPropertyBindings.Single().NavigationProperty;
 }
开发者ID:tlycken,项目名称:aspnetwebstack,代码行数:5,代码来源:ODataEntityReferenceLinkDeserializerTests.cs

示例8: ExtractEntityContainer

 private static IEdmEntityContainer ExtractEntityContainer(IEdmModel model)
 {
     IEnumerable<IEdmEntityContainer> containers = model.EntityContainers();
     int containerCount = containers.Count();
     if (containerCount != 1)
     {
         throw Error.Argument("model", SRResources.ParserModelMustHaveOneContainer, containerCount);
     }
     return containers.Single();
 }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:10,代码来源:DefaultODataPathHandler.cs

示例9: CreatePath

 private static ODataPath CreatePath(IEdmModel model, string actionName)
 {
     IEdmFunctionImport functionImport =
         model.EntityContainers().Single().FindFunctionImports(actionName).Single();
     return new ODataPath(new ActionPathSegment(functionImport));
 }
开发者ID:brianly,项目名称:aspnetwebstack,代码行数:6,代码来源:ODataActionPayloadDeserializerTest.cs

示例10: ODataActionPayloadDeserializerTest

 static ODataActionPayloadDeserializerTest()
 {
     _model = GetModel();
     _container = _model.EntityContainers().SingleOrDefault();
     _deserializer = new ODataActionPayloadDeserializer(new DefaultODataDeserializerProvider());
 }
开发者ID:modulexcite,项目名称:aspnetwebstack-1,代码行数:6,代码来源:ODataActionPayloadDeserializerTest.cs

示例11: CreatePath

 private static ODataPath CreatePath(IEdmModel model, string actionName)
 {
     IEdmActionImport actionImport =
         model.EntityContainers().Single().FindOperationImports(actionName).Single() as IEdmActionImport;
     Assert.NotNull(actionImport);
     return new ODataPath(new ActionPathSegment(actionImport));
 }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:7,代码来源:ODataActionPayloadDeserializerTest.cs

示例12: TryGetEntitySetAndEntityType

        /// <summary>
        /// Tries to get entity set.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="model">The model.</param>
        /// <param name="entitySet">The entity set.</param>
        /// <returns>
        /// True  if it gets and entitySet or false if it can't
        /// </returns>
        public static bool TryGetEntitySetAndEntityType(Uri uri, IEdmModel model, out IEdmEntitySet entitySet)
        {
            IEdmEntitySet currentEntitySet = null;

            entitySet = null;
            foreach (string segment in uri.Segments)
            {
                string segmentValue = segment.Replace("/", String.Empty);

                if (segmentValue.Length == 0)
                {
                    continue;
                }

                // lopping off key pieces as we don't care
                int i = segment.IndexOf('(');
                if (i > -1)
                {
                    segmentValue = segment.Remove(i);
                }

                IEdmEntityContainer container = model.EntityContainers().First();
                // If there is no entitySet we need to find out which one it is
                if (currentEntitySet == null)
                {
                    IEdmEntitySet foundEntitySet = container.FindEntitySet(segmentValue);
                    if (foundEntitySet != null)
                    {
                        currentEntitySet = foundEntitySet;
                    }
                    else
                    {
                        // check to see if there the current segment is a service operation
                        IEdmFunctionImport functionImport = container.FunctionImports().SingleOrDefault(fi => fi.Name == segmentValue);
                        if (functionImport != null)
                        {
                            IEdmEntitySet functionEntitySet = null;
                            if (functionImport.TryGetStaticEntitySet(out functionEntitySet))
                            {
                                currentEntitySet = functionEntitySet;
                            }
                        }
                    }
                }
                else
                {
                    IEdmNavigationProperty navigationProperty = currentEntitySet.ElementType.NavigationProperties().SingleOrDefault(np => np.Name == segmentValue);
                    if (navigationProperty != null)
                    {
                        currentEntitySet = currentEntitySet.FindNavigationTarget(navigationProperty);
                    }
                    else
                    {
                        // Need to update this a little so it works for Actions/Functions
                        IEdmFunctionImport functionImport = container.FunctionImports().SingleOrDefault(fi => fi.IsBindable == true && fi.Name == segmentValue);
                        if (functionImport != null)
                        {
                            IEdmEntitySet functionEntitySet = null;
                            if (functionImport.TryGetStaticEntitySet(out functionEntitySet))
                            {
                                currentEntitySet = functionEntitySet;
                            }
                        }
                    }
                }
            }

            if (currentEntitySet != null)
            {
                entitySet = currentEntitySet;
                return true;
            }

            entitySet = null;

            return false;
        }
开发者ID:mikevpeters,项目名称:aspnetwebstack,代码行数:86,代码来源:ODataUriHelpers.cs


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