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


C# EntityModelSchema.GetEntitySet方法代码示例

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


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

示例1: GenerateRequestOperation

        private IHttpRequest GenerateRequestOperation(ODataResponse batchResponseOperation, EntityModelSchema model)
        {
            ExceptionUtilities.CheckArgumentNotNull(batchResponseOperation, "batchResponseOperation");
            ExceptionUtilities.CheckArgumentNotNull(model, "model");
            var headers = new Dictionary<string, string> { { "GivenPayloadRequestHeader", "PayloadHeaderValue" } };
            
            string mergeContentType = HttpUtilities.BuildContentType(MimeTypes.ApplicationXml, Encoding.UTF8.WebName, null);
            ODataUri uri = null;
            HttpVerb verb = HttpVerb.Get;
            if (batchResponseOperation.RootElement != null)
            {
                var complexInstanceCollection = batchResponseOperation.RootElement as ComplexInstanceCollection;
                if (complexInstanceCollection != null)
                {
                    var function = batchResponseOperation.RootElement.GetAnnotation<FunctionAnnotation>();
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.ServiceOperation(function.Function));
                }

                var complexMultivalue = batchResponseOperation.RootElement as ComplexMultiValueProperty;
                if (complexMultivalue != null)
                {
                    var entityType = complexMultivalue.GetAnnotation<EntityModelTypeAnnotation>().EntityModelType as EntityDataType;
                    var entitySet = model.GetEntitySet(entityType.Definition.Name);
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(entitySet), ODataUriBuilder.Property(entityType.Definition, complexMultivalue.Name));
                }

                var complexProperty = batchResponseOperation.RootElement as ComplexProperty;
                if (complexProperty != null)
                {
                    var type = complexProperty.GetAnnotation<EntityModelTypeAnnotation>();
                    var complexDataType = type.EntityModelType as ComplexDataType;
                    // Using first because we don't need a specific entity just one that contains this type. If there is more than one the first works fine.
                    var entityType = model.EntityTypes.Where(et => et.Properties.Where(p => p.Name == complexProperty.Name).Count() == 1).First();
                    var complexType = model.ComplexTypes.Where(ct => complexDataType.Definition.Name == ct.Name).Single();
                    var complexPropertyName = entityType.AllProperties.Where(p => 
                        {
                            var complex = p.PropertyType as ComplexDataType;
                            if (complex == null)
                            {
                                return false;
                            }

                            return complex.Definition.Name == complexDataType.Definition.Name;

                        }).Single();
                    
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.Property(entityType, complexPropertyName.Name));
                }

                var deferredLink = batchResponseOperation.RootElement as DeferredLink;
                if (deferredLink != null)
                {
                    var navigationProperty = deferredLink.GetAnnotation<NavigationPropertyAnnotation>();
                    var entityType = model.EntityTypes.Where(et => et.Properties.Where(p => p.Name == navigationProperty.Property.Name).Count() == 1).First();
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.Property(entityType, navigationProperty.Property.Name));
                }

                var linkCollection = batchResponseOperation.RootElement as LinkCollection;
                if (linkCollection != null)
                {
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), SystemSegment.EntityReferenceLinks);
                }

                var entityInstance = batchResponseOperation.RootElement as EntityInstance;
                if (entityInstance != null)
                {
                    var type = entityInstance.GetAnnotation<EntityModelTypeAnnotation>().EntityModelType as EntityDataType;
                    var entitySetType = model.GetEntitySet(type.Definition.Name);
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(entitySetType));
                }

                var entitySetInstance = batchResponseOperation.RootElement as EntitySetInstance;
                if (entitySetInstance != null)
                {
                    var entitySetType = model.GetEntitySet(entityInstance.FullTypeName);
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(entitySetType));
                }

                var primitiveCollection = batchResponseOperation.RootElement as PrimitiveCollection;
                if (primitiveCollection != null)
                {
                    var function = batchResponseOperation.RootElement.GetAnnotation<FunctionAnnotation>();
                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.ServiceOperation(function.Function));
                }

                var primitiveMultiValueProperty = batchResponseOperation.RootElement as PrimitiveMultiValueProperty;
                if (primitiveMultiValueProperty != null)
                {
                    var type = primitiveMultiValueProperty.GetAnnotation<EntityModelTypeAnnotation>();
                    var entityType = type.EntityModelType as EntityDataType;

                    uri = new ODataUri(ODataUriBuilder.Root(new Uri("http://www.odata.org")), ODataUriBuilder.EntitySet(model.GetEntitySet(entityType.Definition.Name)), ODataUriBuilder.Property(entityType.Definition, primitiveMultiValueProperty.Name));
                }

                var primitiveProperty = batchResponseOperation.RootElement as PrimitiveProperty;
                if (primitiveProperty != null)
                {
                    var type = complexProperty.GetAnnotation<EntityModelTypeAnnotation>();
                    var entityType = type.EntityModelType as EntityDataType;

//.........这里部分代码省略.........
开发者ID:AlineGuan,项目名称:odata.net,代码行数:101,代码来源:BatchResponseToDummyRequestGenerator.cs


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