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


C# ODataConventionModelBuilder.ComplexType方法代码示例

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


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

示例1: GetSampleModel

 private static IEdmModel GetSampleModel()
 {
     ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
     builder.ComplexType<Person>();
     return builder.GetEdmModel();
 }
开发者ID:Swethach,项目名称:aspnetwebstack,代码行数:6,代码来源:CollectionTest.cs

示例2: ConfigOData

        private static void ConfigOData(HttpConfiguration config)
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();

            var conventions = ODataRoutingConventions.CreateDefault();
            conventions.Insert(0, new CompositeKeyRoutingConvention());

            builder.ComplexType<Address>();

            builder.EntitySet<Brand>("Brands").EntityType.Collection
                .Action("FormLookups")
                .Returns<Components.BrandFormLookups>();
            builder.EntitySet<Client>("Clients");
            builder.EntitySet<Company>("Companies");
            builder.EntitySet<Condition>("Conditions");
            builder.EntitySet<Job>("Jobs").EntityType.Collection
                .Action("FormLookups")
                .Returns<Components.JobFormLookups>();
            builder.EntitySet<JobRepairReason>("JobRepairReasons");
            builder.EntitySet<JobWorkDone>("JobWorkDone");
            builder.EntitySet<Model>("Models").EntityType.Collection
                .Action("FormLookups")
                .Returns<Components.ModelFormLookups>();
            builder.EntitySet<RepairReason>("RepairReasons");
            builder.EntitySet<User>("Users");
            builder.EntitySet<WorkDone>("WorkDone");

            builder.ComplexType<Components.KeyValueResult<string, string>>();

            var EDM = builder.GetEdmModel();

            // OData v4.0
            //config.MapODataServiceRoute("odata", "odata", EDM,
            //    new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));

            config.Routes.MapODataServiceRoute("odata", "odata", EDM,
                new DefaultODataPathHandler(),
                conventions,
                new DefaultODataBatchHandler(GlobalConfiguration.DefaultServer));
        }
开发者ID:AymanGaafar,项目名称:RepairShop,代码行数:40,代码来源:WebApiConfig.cs

示例3: CreateServer

        private static HttpServer CreateServer(string customersEntitySet)
        {
            HttpConfiguration configuration = new HttpConfiguration();

            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet<EnableQueryCustomer>(customersEntitySet);
            builder.Entity<PremiumEnableQueryCustomer>();

            builder.EntitySet<EnableQueryCategory>("EnableQueryCategories");
            builder.Entity<PremiumEnableQueryCategory>();

            builder.EntitySet<EnableQueryOrder>("EnableQueryOrders");
            builder.Entity<DiscountedEnableQueryOrder>();

            builder.EntitySet<EnableQueryOrderLine>("EnableQueryOrderLines");

            builder.ComplexType<EnableQueryAddress>();

            IEdmModel model = builder.GetEdmModel();

            configuration.Routes.MapODataServiceRoute("odata", "odata", model);

            return new HttpServer(configuration);
        }
开发者ID:AndreGleichner,项目名称:aspnetwebstack,代码行数:25,代码来源:EnableQueryTest.cs

示例4: GetEdmModel

        private static IEdmModel GetEdmModel()
        {
            ODataModelBuilder modelBuilder = new ODataConventionModelBuilder();
            modelBuilder.ContainerName = "WebApiCtx";

            //modelBuilder.EntitySet<TestDataObj>("Values");
            var holidays = modelBuilder.EntitySet<Model.WorkCalendar>("Holidays");
            holidays.EntityType.Property(h => h.Comment).IsOptional();
            holidays.EntityType.Ignore(h => h.DayType);
            holidays.EntityType.Ignore(h => h.BankDate);
            holidays.EntityType.Ignore(h => h.BankDate_Key);

            //var companies = modelBuilder.EntitySet<Model.Company>("Companies");
            var govs = modelBuilder.EntitySet<Model.Governor>("Governors");
            govs.HasEditLink(
                entityContext => entityContext.Url.ODataLink(
                    new EntitySetPathSegment(entityContext.EntitySet.Name),
                    new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(entityContext.EntityInstance.Id, ODataVersion.V3))),
                followsConventions: true);

            var c = modelBuilder.ComplexType<Model.Company>();
            c.Property(o => o.lawFormValue);
            c.Ignore(o => o.FullName);
            c.Ignore(o => o.LawForm);

            govs.EntityType.ComplexProperty(g => g.Company).IsRequired();

            var assets = modelBuilder.EntitySet<Model.AssetValue>("Assets");
            assets.HasEditLink(
                entityContext => entityContext.Url.ODataLink(
                    new EntitySetPathSegment(entityContext.EntitySet.Name),
                    new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(entityContext.EntityInstance.Id, ODataVersion.V3))),
                followsConventions: true);

            assets.HasRequiredBinding(a => a.Governor, govs);
            assets.EntityType.Property(a => a.InsuranceTypeValue).IsRequired();
            //assets.EntityType.ComplexProperty(a => a.Governor);
            assets.EntityType.Ignore(a => a.InsuranceType);
            assets.EntityType.Ignore(a => a.InsuranceTypeString);

            assets.HasNavigationPropertiesLink(
                assets.EntityType.NavigationProperties,
                (entityContext, navigationProperty) =>
                    new Uri(entityContext.Url.ODataLink(
                        new EntitySetPathSegment(entityContext.EntitySet.Name),
                        new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(entityContext.EntityInstance.Id, ODataVersion.V3)),
                        new NavigationPathSegment(navigationProperty.Name))),
                followsConventions: true);

            govs.HasNavigationPropertiesLink(
                govs.EntityType.NavigationProperties,
                (entityContext, navigationProperty) =>
                    new Uri(entityContext.Url.ODataLink(
                        new EntitySetPathSegment(entityContext.EntitySet.Name),
                        new KeyValuePathSegment(ODataUriUtils.ConvertToUriLiteral(entityContext.EntityInstance.Id, ODataVersion.V3)),
                        new NavigationPathSegment(navigationProperty.Name))),
                followsConventions: true);

            var actionRep = assets.EntityType.Collection.Action("Report");
            actionRep.Parameter<DateTime>("DateBegin");
            actionRep.Parameter<DateTime>("DateEnd");
            actionRep.Parameter<byte>("InsuranceType");
            actionRep.Parameter<Guid?>("GovernorId");
            actionRep.Returns<string>();

            var actionBatch = assets.EntityType.Collection.Action("CreateBatch");
            actionBatch.CollectionParameter<string>("Values");
            actionBatch.Returns<bool>();

            IEdmModel model = modelBuilder.GetEdmModel();
            return model;
        }
开发者ID:koder05,项目名称:fogel-ba,代码行数:72,代码来源:WebApiConfig.cs


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