• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# IEdmEntitySet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中IEdmEntitySet的典型用法代码示例。如果您正苦于以下问题:C# IEdmEntitySet类的具体用法?C# IEdmEntitySet怎么用?C# IEdmEntitySet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



IEdmEntitySet类属于命名空间,在下文中一共展示了IEdmEntitySet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ConvertToODataEntry

        /// <summary>
        /// Converts an item from the data store into an ODataEntry.
        /// </summary>
        /// <param name="element">The item to convert.</param>
        /// <param name="entitySet">The entity set that the item belongs to.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <returns>The converted ODataEntry.</returns>
        public static ODataEntry ConvertToODataEntry(object element, IEdmEntitySet entitySet, ODataVersion targetVersion)
        {
            IEdmEntityType entityType = entitySet.EntityType();

            Uri entryUri = BuildEntryUri(element, entitySet, targetVersion);

            var entry = new ODataEntry
            {
                // writes out the edit link including the service base uri  , e.g.: http://<serviceBase>/Customers('ALFKI')
                EditLink = entryUri,

                // writes out the self link including the service base uri  , e.g.: http://<serviceBase>/Customers('ALFKI')
                ReadLink = entryUri,

                // we use the EditLink as the Id for this entity to maintain convention,
                Id = entryUri,

                // writes out the <category term='Customer'/> element 
                TypeName = element.GetType().Namespace + "." + entityType.Name,

                Properties = entityType.StructuralProperties().Select(p => ConvertToODataProperty(element, p.Name)),
            };

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


示例2: SetCountRestrictionsAnnotation

        /// <summary>
        /// Set Org.OData.Capabilities.V1.CountRestrictions to target.
        /// </summary>
        /// <param name="model">The model referenced to.</param>
        /// <param name="target">The target entity set to set the inline annotation.</param>
        /// <param name="isCountable">This entity set can be counted.</param>
        /// <param name="nonCountableProperties">These collection properties do not allow /$count segments.</param>
        /// <param name="nonCountableNavigationProperties">These navigation properties do not allow /$count segments.</param>
        public static void SetCountRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target, bool isCountable,
            IEnumerable<IEdmProperty> nonCountableProperties,
            IEnumerable<IEdmNavigationProperty> nonCountableNavigationProperties)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

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

            nonCountableProperties = nonCountableProperties ?? EmptyStructuralProperties;
            nonCountableNavigationProperties = nonCountableNavigationProperties ?? EmptyNavigationProperties;

            IList<IEdmPropertyConstructor> properties = new List<IEdmPropertyConstructor>
            {
                new EdmPropertyConstructor(CapabilitiesVocabularyConstants.CountRestrictionsCountable,
                    new EdmBooleanConstant(isCountable)),

                new EdmPropertyConstructor(CapabilitiesVocabularyConstants.CountRestrictionsNonCountableProperties,
                    new EdmCollectionExpression(
                        nonCountableProperties.Select(p => new EdmPropertyPathExpression(p.Name)).ToArray())),

                new EdmPropertyConstructor(CapabilitiesVocabularyConstants.CountRestrictionsNonCountableNavigationProperties,
                    new EdmCollectionExpression(
                        nonCountableNavigationProperties.Select(p => new EdmNavigationPropertyPathExpression(p.Name)).ToArray()))
            };

            model.SetVocabularyAnnotation(target, properties, CapabilitiesVocabularyConstants.CountRestrictions);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:41,代码来源:CapabilitiesVocabularyExtensionMethods.cs


示例3: CreateODataEntry

        /// <summary>
        /// Creates a new ODataEntry from the specified entity set, instance, and type.
        /// </summary>
        /// <param name="entitySet">Entity set for the new entry.</param>
        /// <param name="value">Entity instance for the new entry.</param>
        /// <param name="entityType">Entity type for the new entry.</param>
        /// <returns>New ODataEntry with the specified entity set and type, property values from the specified instance.</returns>
        internal static ODataEntry CreateODataEntry(IEdmEntitySet entitySet, IEdmStructuredValue value, IEdmEntityType entityType)
        {
            var entry = new ODataEntry();
            entry.SetAnnotation(new ODataTypeAnnotation(entitySet, entityType));
            entry.Properties = value.PropertyValues.Select(p =>
            {
                object propertyValue;
                if (p.Value.ValueKind == EdmValueKind.Null)
                {
                    propertyValue = null;
                }
                else if (p.Value is IEdmPrimitiveValue)
                {
                    propertyValue = ((IEdmPrimitiveValue)p.Value).ToClrValue();
                }
                else
                {
                    Assert.Fail("Test only currently supports creating ODataEntry from IEdmPrimitiveValue instances.");
                    return null;
                }

                return new ODataProperty() { Name = p.Name, Value = propertyValue };
            });

            return entry;
        }
开发者ID:rossjempson,项目名称:odata.net,代码行数:33,代码来源:TestUtils.cs


示例4: EntitySetNode

 /// <summary>
 /// Creates an <see cref="EntitySetNode"/>
 /// </summary>
 /// <param name="entitySet">The entity set this node represents</param>
 /// <exception cref="System.ArgumentNullException">Throws if the input entitySet is null.</exception>
 public EntitySetNode(IEdmEntitySet entitySet)
 {
     ExceptionUtils.CheckArgumentNotNull(entitySet, "entitySet");
     this.entitySet = entitySet;
     this.entityType = new EdmEntityTypeReference(this.NavigationSource.EntityType(), false);
     this.collectionTypeReference = EdmCoreModel.GetCollection(this.entityType);
 }
开发者ID:larsenjo,项目名称:odata.net,代码行数:12,代码来源:EntitySetNode.cs


示例5: EntitySetInfo

        internal EntitySetInfo(IEdmModel edmModel, IEdmEntitySet edmEntitySet, ITypeResolver typeResolver)
        {
            Contract.Assert(edmModel != null);
            Contract.Assert(edmEntitySet != null);
            Contract.Assert(typeResolver != null);

            Name = edmEntitySet.Name;
            ElementType = new EntityTypeInfo(edmModel, edmEntitySet.ElementType, typeResolver);
            var entityTypes = new List<EntityTypeInfo>(3) { ElementType };

            // Create an EntityTypeInfo for any derived types in the model
            foreach (var edmDerivedType in edmModel.FindAllDerivedTypes(edmEntitySet.ElementType).OfType<IEdmEntityType>())
            {
                entityTypes.Add(new EntityTypeInfo(edmModel, edmDerivedType, typeResolver));
            }

            // Connect any derived types with their base class
            for (int i = 1; i < entityTypes.Count; ++i)
            {
                var baseEdmEntityType = entityTypes[i].EdmEntityType.BaseEntityType();
                if (baseEdmEntityType != null)
                {
                    var baseEntityTypeInfo = entityTypes.First(entityTypeInfo => entityTypeInfo.EdmEntityType == baseEdmEntityType);
                    if (baseEntityTypeInfo != null)
                    {
                        entityTypes[i].BaseTypeInfo = baseEntityTypeInfo;
                    }
                }
            }

            EntityTypes = entityTypes;
        }
开发者ID:entityrepository,项目名称:ODataClient,代码行数:32,代码来源:EntitySetInfo.cs


示例6: SetEntitySetLinkBuilder

        public static void SetEntitySetLinkBuilder(this IEdmModel model, IEdmEntitySet entitySet, EntitySetLinkBuilderAnnotation entitySetLinkBuilder)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

            model.SetAnnotationValue(entitySet, entitySetLinkBuilder);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:9,代码来源:EdmModelExtensions.cs


示例7: EntitySetPathSegment

        /// <summary>
        /// Initializes a new instance of the <see cref="EntitySetPathSegment" /> class.
        /// </summary>
        /// <param name="entitySet">The entity set being accessed.</param>
        public EntitySetPathSegment(IEdmEntitySet entitySet)
        {
            if (entitySet == null)
            {
                throw Error.ArgumentNull("entitySet");
            }

            EntitySet = entitySet;
            EntitySetName = entitySet.Name;
        }
开发者ID:nicholaspei,项目名称:aspnetwebstack,代码行数:14,代码来源:EntitySetPathSegment.cs


示例8: EntitySetPathSegment

        /// <summary>
        /// Initializes a new instance of the <see cref="EntitySetPathSegment" /> class.
        /// </summary>
        /// <param name="entitySet">The entity set being accessed.</param>
        public EntitySetPathSegment(IEdmEntitySet entitySet)
        {
            if (entitySet == null)
            {
                throw Error.ArgumentNull("entitySet");
            }

            EdmType = entitySet.ElementType.GetCollection();
            EntitySet = entitySet;
        }
开发者ID:cubski,项目名称:aspnetwebstack,代码行数:14,代码来源:EntitySetPathSegment.cs


示例9: GetEntitySetLinkBuilder

        internal static IEntitySetLinkBuilder GetEntitySetLinkBuilder(this IEdmModel model, IEdmEntitySet entitySet)
        {
            IEntitySetLinkBuilder annotation = model.GetAnnotationValue<IEntitySetLinkBuilder>(entitySet);
            if (annotation == null)
            {
                throw Error.NotSupported(SRResources.EntitySetHasNoBuildLinkAnnotation, entitySet.Name);
            }

            return annotation;
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:10,代码来源:EdmModelHelperMethods.cs


示例10: SetNavigationTarget

        /// <summary>
        /// Sets the navigation target for a particular navigation property.
        /// </summary>
        /// <param name="navigationProperty">The navigation property.</param>
        /// <param name="target">The target entity set.</param>
        public void SetNavigationTarget(IEdmNavigationProperty navigationProperty, IEdmEntitySet target)
        {
            this.navigationTargets[navigationProperty] = target;

            var stubTarget = (StubEdmEntitySet)target;
            if (stubTarget.FindNavigationTarget(navigationProperty.Partner) != this) 
            {
                stubTarget.SetNavigationTarget(navigationProperty.Partner, this);
            }
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:15,代码来源:StubEdmEntitySet.cs


示例11: WriteEntry

        /// <summary>
        /// Writes an OData entry.
        /// </summary>
        /// <param name="writer">The ODataWriter that will write the entry.</param>
        /// <param name="element">The item from the data store to write.</param>
        /// <param name="entitySet">The entity set in the model that the entry belongs to.</param>
        /// <param name="model">The data store model.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <param name="expandedNavigationProperties">A list of navigation property names to expand.</param>
        public static void WriteEntry(ODataWriter writer, object element, IEdmEntitySet entitySet, IEdmModel model, ODataVersion targetVersion, IEnumerable<string> expandedNavigationProperties) 
        {
            var entry = ODataObjectModelConverter.ConvertToODataEntry(element, entitySet, targetVersion);

            writer.WriteStart(entry);

            // Here, we write out the links for the navigation properties off of the entity type
            WriteNavigationLinks(writer, element, entry.ReadLink, entitySet.EntityType(), model, targetVersion, expandedNavigationProperties);

            writer.WriteEnd();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:20,代码来源:ResponseWriter.cs


示例12: EntitySetPathSegment

        /// <summary>
        /// Initializes a new instance of the <see cref="EntitySetPathSegment" /> class.
        /// </summary>
        /// <param name="previous">The previous segment in the path.</param>
        /// <param name="entitySet">The entity set being accessed.</param>
        public EntitySetPathSegment(ODataPathSegment previous, IEdmEntitySet entitySet)
            : base(previous)
        {
            if (entitySet == null)
            {
                throw Error.ArgumentNull("entitySet");
            }

            EdmType = entitySet.ElementType.GetCollection();
            EntitySet = entitySet;
        }
开发者ID:marojeri,项目名称:aspnetwebstack,代码行数:16,代码来源:EntitySetPathSegment.cs


示例13: WriteFeed

        /// <summary>
        /// Writes an OData feed.
        /// </summary>
        /// <param name="writer">The ODataWriter that will write the feed.</param>
        /// <param name="entries">The items from the data store to write to the feed.</param>
        /// <param name="entitySet">The entity set in the model that the feed belongs to.</param>
        /// <param name="model">The data store model.</param>
        /// <param name="targetVersion">The OData version this segment is targeting.</param>
        /// <param name="expandedNavigationProperties">A list of navigation property names to expand.</param>
        public static void WriteFeed(ODataWriter writer, IEnumerable entries, IEdmEntitySet entitySet, IEdmModel model, ODataVersion targetVersion, IEnumerable<string> expandedNavigationProperties)
        {
            var feed = new ODataFeed {Id = new Uri(ServiceConstants.ServiceBaseUri, entitySet.Name)};
            writer.WriteStart(feed);

            foreach (var element in entries)
            {
                WriteEntry(writer, element, entitySet, model, targetVersion, expandedNavigationProperties);
            }

            writer.WriteEnd();
        }
开发者ID:larsenjo,项目名称:odata.net,代码行数:21,代码来源:ResponseWriter.cs


示例14: EdmEntitySetFacade

        /// <summary>
        /// Initializes a new instance of the <see cref="EdmEntitySetFacade"/> class.
        /// </summary>
        /// <param name="serverEntitySet">The entity set from the server model.</param>
        /// <param name="containerFacade">The entity container facade to which the set belongs.</param>
        /// <param name="modelFacade">The model facade.</param>
        internal EdmEntitySetFacade(IEdmEntitySet serverEntitySet, EdmEntityContainerFacade containerFacade, EdmModelFacade modelFacade)
        {
            Debug.Assert(serverEntitySet != null, "serverEntitySet != null");
            Debug.Assert(containerFacade != null, "container != null");
            Debug.Assert(modelFacade != null, "modelFacade != null");

            this.serverEntitySet = serverEntitySet;
            this.Container = containerFacade;
            this.modelFacade = modelFacade;
            
            this.Name = this.serverEntitySet.Name;
        }
开发者ID:AlineGuan,项目名称:odata.net,代码行数:18,代码来源:EdmEntitySetFacade.cs


示例15: EntitySetMetadata

		internal EntitySetMetadata(Type contextType, IContainerMetadata container, IEdmEntitySet edmEntitySet, IEntityTypeMetadata entityTypeMetadata, IEntityTypeMetadata[] entityTypeHierarchyMetadata)
		{
			Contract.Assert(container != null);
			Contract.Assert(edmEntitySet != null);
			Contract.Assert(entityTypeMetadata != null);
			Contract.Assert(entityTypeHierarchyMetadata != null);
			Contract.Assert(entityTypeHierarchyMetadata.Length >= 1);

			ContextType = contextType;
			ContainerMetadata = container;
			_edmEntitySet = edmEntitySet;
			ElementTypeMetadata = entityTypeMetadata;
			ElementTypeHierarchyMetadata = entityTypeHierarchyMetadata;
		}
开发者ID:mdabbagh88,项目名称:ODataServer,代码行数:14,代码来源:EntitySetMetadata.cs


示例16: SetNavigationRestrictionsAnnotation

        /// <summary>
        /// Set Org.OData.Capabilities.V1.NavigationRestrictions to target.
        /// </summary>
        /// <param name="model">The model referenced to.</param>
        /// <param name="target">The target entity set to set the inline annotation.</param>
        /// <param name="navigability">This entity set supports navigability.</param>
        /// <param name="restrictedProperties">These properties have navigation restrictions on.</param>
        public static void SetNavigationRestrictionsAnnotation(this EdmModel model, IEdmEntitySet target,
            CapabilitiesNavigationType navigability,
            IEnumerable<Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>> restrictedProperties)
        {
            if (model == null)
            {
                throw Error.ArgumentNull("model");
            }

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

            IEdmEnumType navigationType = model.GetCapabilitiesNavigationType();
            if (navigationType == null)
            {
                return;
            }

            restrictedProperties = restrictedProperties ?? new Tuple<IEdmNavigationProperty, CapabilitiesNavigationType>[0];

            string type = new EdmEnumTypeReference(navigationType, false).ToStringLiteral((long)navigability);

            IEnumerable<EdmRecordExpression> propertiesExpression = restrictedProperties.Select(p =>
            {
                var name = new EdmEnumTypeReference(navigationType, false).ToStringLiteral((long)p.Item2);
                return new EdmRecordExpression(new IEdmPropertyConstructor[]
                {
                    new EdmPropertyConstructor(
                        CapabilitiesVocabularyConstants.NavigationPropertyRestrictionNavigationProperty,
                        new EdmNavigationPropertyPathExpression(p.Item1.Name)),
                    new EdmPropertyConstructor(CapabilitiesVocabularyConstants.NavigationRestrictionsNavigability,
                        new EdmEnumMemberReferenceExpression(navigationType.Members.Single(m => m.Name == name)))
                });
            });

            IList<IEdmPropertyConstructor> properties = new List<IEdmPropertyConstructor>
            {
                new EdmPropertyConstructor(CapabilitiesVocabularyConstants.NavigationRestrictionsNavigability,
                    new EdmEnumMemberReferenceExpression(
                        navigationType.Members.Single(m => m.Name == type))),

                new EdmPropertyConstructor(CapabilitiesVocabularyConstants.NavigationRestrictionsRestrictedProperties,
                    new EdmCollectionExpression(propertiesExpression))
            };

            model.SetVocabularyAnnotation(target, properties, CapabilitiesVocabularyConstants.NavigationRestrictions);
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:56,代码来源:CapabilitiesVocabularyExtensionMethods.cs


示例17: FeedContext

        /// <summary>
        /// Initializes a new instance of the <see cref="FeedContext" /> class.
        /// </summary>
        /// <param name="entitySet">The entity set.</param>
        /// <param name="urlHelper">The URL helper.</param>
        /// <param name="feedInstance">The feed instance.</param>
        public FeedContext(IEdmEntitySet entitySet, UrlHelper urlHelper, object feedInstance)
        {
            if (entitySet == null)
            {
                throw Error.ArgumentNull("entitySet");
            }

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

            EntitySet = entitySet;
            UrlHelper = urlHelper;
            FeedInstance = feedInstance;
        }
开发者ID:chrissimon-au,项目名称:aspnetwebstack,代码行数:22,代码来源:FeedContext.cs


示例18: ParameterAliasNodeTranslatorTest

        public ParameterAliasNodeTranslatorTest()
        {
            var builder = new ODataConventionModelBuilder();
            builder.EntitySet<ParameterAliasCustomer>("Customers");
            builder.EntitySet<ParameterAliasOrder>("Orders");

            builder.EntityType<ParameterAliasCustomer>().Function("CollectionFunctionCall")
                .ReturnsCollection<int>().Parameter<int>("p1");

            builder.EntityType<ParameterAliasCustomer>().Function("EntityCollectionFunctionCall")
                .ReturnsCollectionFromEntitySet<ParameterAliasCustomer>("Customers").Parameter<int>("p1");

            builder.EntityType<ParameterAliasCustomer>().Function("SingleEntityFunctionCall")
                .Returns<ParameterAliasCustomer>().Parameter<int>("p1");

            builder.EntityType<ParameterAliasCustomer>().Function("SingleEntityFunctionCallWithoutParameters")
                .Returns<ParameterAliasCustomer>();

            builder.EntityType<ParameterAliasCustomer>().Function("SingleValueFunctionCall")
                .Returns<int>().Parameter<int>("p1");

            _model = builder.GetEdmModel();
            _customersEntitySet = _model.FindDeclaredEntitySet("Customers");
            _customerEntityType = _customersEntitySet.EntityType();
            _parameterAliasMappedNode = new ConstantNode(123);
        }
开发者ID:ahmetgoktas,项目名称:aspnetwebstack,代码行数:26,代码来源:ParameterAliasNodeTranslatorTest.cs


示例19: ODataFeedSerializerTests

        public ODataFeedSerializerTests()
        {
            _model = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
            _customers = new[] {
                new Customer()
                {
                    FirstName = "Foo",
                    LastName = "Bar",
                    ID = 10,
                },
                new Customer()
                {
                    FirstName = "Foo",
                    LastName = "Bar",
                    ID = 42,
                }
            };

            _customersType = new EdmCollectionTypeReference(
                    new EdmCollectionType(
                        new EdmEntityTypeReference(
                            _customerSet.ElementType,
                            isNullable: false)),
                    isNullable: false);

            _urlHelper = new Mock<UrlHelper>(new HttpRequestMessage()).Object;
            _writeContext = new ODataSerializerWriteContext(new ODataResponseContext()) { EntitySet = _customerSet, UrlHelper = _urlHelper };
        }
开发者ID:chrisortman,项目名称:aspnetwebstack,代码行数:29,代码来源:ODataFeedSerializerTests.cs


示例20: ODataFeedSerializerTests

        public ODataFeedSerializerTests()
        {
            _model = SerializationTestsHelpers.SimpleCustomerOrderModel();
            _customerSet = _model.FindDeclaredEntityContainer("Default.Container").FindEntitySet("Customers");
            _customers = new[] {
                new Customer()
                {
                    FirstName = "Foo",
                    LastName = "Bar",
                    ID = 10,
                },
                new Customer()
                {
                    FirstName = "Foo",
                    LastName = "Bar",
                    ID = 42,
                }
            };

            _customersType = new EdmCollectionTypeReference(
                    new EdmCollectionType(
                        new EdmEntityTypeReference(
                            _customerSet.ElementType,
                            isNullable: false)),
                    isNullable: false);

            _writeContext = new ODataSerializerContext() { EntitySet = _customerSet, Model = _model };
        }
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:28,代码来源:ODataFeedSerializerTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# IEdmEntityType类代码示例发布时间:2022-05-24
下一篇:
C# IEdmElement类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap