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


C# IEdmModel.GetEdmType方法代码示例

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


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

        /// <summary>
        /// Constructs an instance of <see cref="ODataQueryContext"/> with <see cref="IEdmModel" /> and element CLR type. 
        /// </summary>
        /// <param name="model">The EdmModel that includes the <see cref="IEdmType"/> corresponding to the given <paramref name="elementClrType"/>.</param>
        /// <param name="elementClrType">The CLR type of the element of the collection being queried.</param>
        public ODataQueryContext(IEdmModel model, Type elementClrType)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

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

            ElementType = model.GetEdmType(elementClrType);

            if (ElementType == null)
            {
                throw Error.Argument("elementClrType", SRResources.ClrTypeNotInModel, elementClrType.FullName);
            }

            ElementClrType = elementClrType;
            Model = model;
        }
开发者ID:quentez,项目名称:aspnetwebstack,代码行数:27,代码来源:ODataQueryContext.cs

示例3: ODataQueryContext

        /// <summary>
        /// Constructs an instance of <see cref="ODataQueryContext"/> with <see cref="IEdmModel" />, element CLR type,
        /// and <see cref="ODataPath" />.
        /// </summary>
        /// <param name="model">The EdmModel that includes the <see cref="IEdmType"/> corresponding to
        /// the given <paramref name="elementClrType"/>.</param>
        /// <param name="elementClrType">The CLR type of the element of the collection being queried.</param>
        /// <param name="path">The parsed <see cref="ODataPath"/>.</param>
        public ODataQueryContext(IEdmModel model, Type elementClrType, ODataPath path)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

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

            ElementType = model.GetEdmType(elementClrType);

            if (ElementType == null)
            {
                throw Error.Argument("elementClrType", SRResources.ClrTypeNotInModel, elementClrType.FullName);
            }

            ElementClrType = elementClrType;
            Model = model;
            Path = path;
            NavigationSource = GetNavigationSource(Model, ElementType, path);
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:32,代码来源:ODataQueryContext.cs

示例4: ApplyEdmModelPropertyNamesToSchema

 private static void ApplyEdmModelPropertyNamesToSchema(SchemaRegistry registry, IEdmModel edmModel, Type type)
 {
     var entityReference = registry.GetOrRegister(type);
     if ([email protected] != null)
     {
         var definitionKey = [email protected]("#/definitions/", string.Empty);
         var schemaDefinition = registry.Definitions[definitionKey];
         var edmType = edmModel.GetEdmType(type) as IEdmStructuredType;
         if (edmType != null)
         {
             var edmProperties = new Dictionary<string, Schema>();
             foreach (var property in schemaDefinition.properties)
             {
                 var currentProperty = type.GetProperty(property.Key, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
                 var edmPropertyName = GetEdmPropertyName(currentProperty, edmType);
                 if (edmPropertyName != null)
                 {
                     edmProperties.Add(edmPropertyName, property.Value);
                 }
             }
             schemaDefinition.properties = edmProperties;
         }
     }
 }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:24,代码来源:SchemaRegistryExtensions.cs


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