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


C# ODataConventionModelBuilder.Function方法代码示例

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


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

示例1: GetModel

        private static IEdmModel GetModel()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            EntitySetConfiguration<Trade> tradesConfiguration = builder.EntitySet<Trade>("Trades");

            //Add bound function
            var boundFunction = tradesConfiguration.EntityType.Collection.Function("GetTradingVolume");
            boundFunction.Parameter<string>("productName");
            boundFunction.Parameter<Country>("portingCountry");
            boundFunction.Returns<long?>();

            //Add bound function
            boundFunction = tradesConfiguration.EntityType.Collection.Function("GetTopTrading");
            boundFunction.Parameter<string>("productName");
            boundFunction.ReturnsFromEntitySet<Trade>("Trades");
            boundFunction.IsComposable = true;

            //Add unbound function
            var unboundFunction = builder.Function("GetTradeByCountry");
            unboundFunction.Parameter<Country>("portingCountry");
            unboundFunction.ReturnsCollectionFromEntitySet<Trade>("Trades");

            builder.Namespace = typeof(Country).Namespace;

           return builder.GetEdmModel();
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:26,代码来源:ParameterAliasTest.cs

示例2: GetModel

		public static IEdmModel GetModel()
		{
			ODataModelBuilder builder = new ODataConventionModelBuilder();
			builder.Namespace = "D";
			builder.ContainerName = "Default";

			EntitySetConfiguration<City> cities = builder.EntitySet<City>("City");
			EntitySetConfiguration<Stadium> stadiums = builder.EntitySet<Stadium>("Stadium");

			// Per Collection Stadium
			FunctionConfiguration getStadiumsWithFunction = stadiums.EntityType.Collection.Function("GetStadiumsWithFunction");
			getStadiumsWithFunction.ReturnsCollectionFromEntitySet<Stadium>("Stadium");

			//  Per Collection Stadium, returns single entity
			FunctionConfiguration getStadiumsTest = stadiums.EntityType.Collection.Function("GetStadiumTest");
			getStadiumsTest.Parameter<string>("test");
			getStadiumsTest.Parameter<string>("name");
			getStadiumsTest.ReturnsFromEntitySet<Stadium>("Stadium");

			// Per Entity (Single key property) City
			FunctionConfiguration getStadiumFromCityWithFunction = cities.EntityType.Function("GetStadiumsFromCityWithFunction");
			getStadiumFromCityWithFunction.ReturnsCollectionFromEntitySet<Stadium>("Stadium");

			// Per Entity composite key Stadium
			FunctionConfiguration getCityFromStadiumWithFunction = stadiums.EntityType.Function("GetCityFromStadiumWithFunction");
			getCityFromStadiumWithFunction.ReturnsFromEntitySet<City>("City");

			// Global Function
			builder.Function("GlobalFunction").ReturnsCollectionFromEntitySet<Stadium>("Stadium");

			
			
			return builder.GetEdmModel();
		}
开发者ID:damienbod,项目名称:WebApiODataFunctionsAndKeys,代码行数:34,代码来源:WebApiConfig.cs

示例3: GetConventionModel

        public static IEdmModel GetConventionModel()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            EntitySetConfiguration<Employee> employees = builder.EntitySet<Employee>("Employees");
            EntityTypeConfiguration<Employee> employee = employees.EntityType;
            employee.EnumProperty<Gender>(e => e.Sex).Name = "Gender";

            employee.Collection.Function("GetEarliestTwoEmployees").ReturnsCollectionFromEntitySet<Employee>("Employees");

            var functionConfiguration = builder.Function("GetAddress");
            functionConfiguration.Parameter<int>("id");
            functionConfiguration.Returns<Address>();

            var actionConfiguration = builder.Action("SetAddress");
            actionConfiguration.Parameter<int>("id");
            actionConfiguration.Parameter<Address>("address");
            actionConfiguration.ReturnsFromEntitySet(employees);

            var resetDataSource = builder.Action("ResetDataSource");

            builder.Namespace = typeof(Employee).Namespace;
            builder.EnableLowerCamelCase();
            var edmModel = builder.GetEdmModel();
            return edmModel;
        }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:25,代码来源:LowerCamelCaseEdmModel.cs

示例4: ODataSwaggerConverterTest

 public ODataSwaggerConverterTest()
 {
     var builder = new ODataConventionModelBuilder();
     builder.EntitySet<Customer>("Customers");
     builder.EntitySet<Order>("Orders");
     builder.Function("UnboundFunction").Returns<string>().Parameter<int>("param");
     builder.Action("UnboundAction").Parameter<double>("param");
     builder.EntityType<Customer>().Function("BoundFunction").Returns<double>().Parameter<string>("name");
     _model = builder.GetEdmModel();
 }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:10,代码来源:ODataSwaggerConverterTest.cs

示例5: StoreModel

 static StoreModel()
 {
     var builder = new ODataConventionModelBuilder();
     builder.Namespace = "Microsoft.Restier.WebApi.Test";
     builder.EntitySet<Product>("Products");
     builder.Function("GetBestProduct").ReturnsFromEntitySet<Product>("Products");
     builder.Action("RemoveWorstProduct").ReturnsFromEntitySet<Product>("Products");
     Model = (EdmModel)builder.GetEdmModel();
     Product = (IEdmEntityType)Model.FindType("Microsoft.Restier.WebApi.Test.Product");
 }
开发者ID:adestis-mh,项目名称:RESTier,代码行数:10,代码来源:StoreApi.cs

示例6: GetEdmModel

 private static IEdmModel GetEdmModel()
 {
     var builder = new ODataConventionModelBuilder();
     builder.EntitySet<Customer>("Customers");
     builder.EntitySet<Order>("Orders");
     builder.Function("UnboundFunction").Returns<string>().Parameter<int>("param");
     builder.Action("UnboundAction").Parameter<double>("param");
     builder.EntityType<Customer>().Function("BoundFunction").Returns<double>().Parameter<string>("name");
     return builder.GetEdmModel();
 }
开发者ID:ZhaoYngTest01,项目名称:WebApi,代码行数:10,代码来源:SwaggerMetadataTest.cs

示例7: GetEdmMode

        private IEdmModel GetEdmMode()
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet<OptionSet>("OptionSets");
            builder.EntitySet<OptionSetEntity>("OptionSetEntities");
            builder.EntitySet<GroupItemType>("GroupItemTypes");
            builder.EntitySet<Group>("Groups");
            builder.EntitySet<GroupItem>("GroupItems");

            builder.Function("GetAllTables")
                    .ReturnsCollection<BaseTable>();

            builder.Function("GetAllColumns")
                   .ReturnsCollection<BaseTable>()
                   .Parameter<string>("TableName");

            return builder.GetEdmModel();
        }
开发者ID:DureSameen,项目名称:ContactsCRMOdata,代码行数:19,代码来源:OwinStartup.cs

示例8: GetModel

        private static IEdmModel GetModel()
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder();
            builder.EntitySet<DerivedTypeA>("SetA");
            builder.EntitySet<DerivedTypeB>("SetB");

            builder.EntityType<BaseType>(); // this line is necessary.
            builder.Function("ReturnAll").ReturnsCollection<BaseType>();

            return builder.GetEdmModel();
        }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:11,代码来源:ODataFeedSerializeWithoutNavigationSourceTests.cs

示例9: GetEdmModel

        private static IEdmModel GetEdmModel()
        {
            var builder = new ODataConventionModelBuilder();

            builder.EntitySet<Pin>("Pins");

            builder.Function("Foo").Returns<int>();

            builder.EntityType<Pin>().Collection.Function("Archived").ReturnsCollection<Pin>();

            return builder.GetEdmModel();
        }
开发者ID:rbeauchamp,项目名称:Swashbuckle.OData,代码行数:12,代码来源:RoutePrefixTests.cs

示例10: GetEdmModel

        private static IEdmModel GetEdmModel()
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet<Product2>("Products");

            builder.Function("ProductsWithIds")
                   .ReturnsCollectionFromEntitySet<Product2>("Products")
                   .CollectionParameter<int>("Ids");

            return builder.GetEdmModel();
        }
开发者ID:bigred8982,项目名称:Swashbuckle.OData,代码行数:12,代码来源:FromUriArrayTests.cs

示例11: GetEdmModel

 private static IEdmModel GetEdmModel()
 {
     var builder = new ODataConventionModelBuilder();
     builder.EntitySet<Customer>("Customers");
     builder.EntitySet<Order>("Orders");
     builder.Function("UnboundFunction").Returns<string>().Parameter<int>("param");
     builder.Action("UnboundAction").Parameter<double>("param");
     builder.EntityType<Customer>().Function("BoundFunction").Returns<double>().Parameter<string>("name");
     builder.EntitySet<CompositeKeyItem>("CompositeKeyItems");
     builder.EntityType<CompositeKeyItem>().HasKey(x => new { x.FirstKey, x.SecondKey });
     return builder.GetEdmModel();
 }
开发者ID:chinadragon0515,项目名称:WebApi,代码行数:12,代码来源:SwaggerMetadataTest.cs

示例12: ConfigureSsisService

        public static void ConfigureSsisService(this IAppBuilder app)
        {
            Debug.Assert(app != null);

            //// build EDM model

            var builder = new ODataConventionModelBuilder()
            {
                Namespace = typeof(SsisController).Namespace,
                ContainerName = "DefaultContainer"
            };

            builder.ComplexType<JobParameter>();
            builder.ComplexType<JobStatusResult>();
            builder.EnumType<JobStatus>();
            builder.EnumType<JobParameterType>();

            {
                var function = builder.Function("GetStatus");
                function.Parameter<string>("name").OptionalParameter = false;
                function.Returns<JobStatusResult>();
            }

            {
                var action = builder.Action("Run");
                action.Parameter<string>("name").OptionalParameter = false;
                action.CollectionParameter<JobParameter>("parameters").OptionalParameter = false;
                action.Returns<string>();
            }

            {
                var action = builder.Action("Stop");
                action.Parameter<string>("name").OptionalParameter = false;
                action.Returns<string>();
            }

            var edmModel = builder.GetEdmModel();

            //// configure web API

            var config = new HttpConfiguration() { IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always };
            config.MapODataServiceRoute("SsisService", "ssisservice", edmModel);
            config.Services.Replace(typeof(IHttpControllerSelector), new ClientHttpControllerSelector(config, typeof(SsisServiceHelper)));
            config.EnsureInitialized();

            app.UseWebApi(config);
        }
开发者ID:wei-zhou,项目名称:diamond,代码行数:47,代码来源:SsisServiceHelper.cs

示例13: GetEdmModel

        private static IEdmModel GetEdmModel(HttpConfiguration config)
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder(config);

            builder.EntitySet<Product>("Products");

            var productType = builder.EntityType<Product>();

            // Function bound to a collection
            // Returns the most expensive product, a single entity
            productType.Collection
                .Function("MostExpensive")
                .Returns<double>();

            // Function bound to a collection
            // Returns the top 10 product, a collection
            productType.Collection
                .Function("Top10")
                .ReturnsCollectionFromEntitySet<Product>("Products");

            // Function bound to a single entity
            // Returns the instance's price rank among all products
            productType
                .Function("GetPriceRank")
                .Returns<int>();

            // Function bound to a single entity
            // Accept a string as parameter and return a double
            // This function calculate the general sales tax base on the 
            // state
            productType
                .Function("CalculateGeneralSalesTax")
                .Returns<double>()
                .Parameter<string>("state");

            // Unbound Function
            builder.Function("GetSalesTaxRate")
                .Returns<double>()
                .Parameter<string>("state");

            return builder.GetEdmModel();
        }
开发者ID:tschnittgen,项目名称:Simple.OData.Client,代码行数:42,代码来源:FunctionStartup.cs

示例14: GetModel

        public static IEdmModel GetModel()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            EntitySetConfiguration<Employee> employees = builder.EntitySet<Employee>("Employees");
            EntityTypeConfiguration<Employee> employee = employees.EntityType;

            // Action that adds a skill to the skill set.
            ActionConfiguration actionConfiguration = employee.Action("AddAccessLevel");
            actionConfiguration.Parameter<string>("AccessLevel");// Now action parameters does not support Enum type, so use string instead.
            actionConfiguration.Returns<AccessLevel>();

            // Function that tells whether an employee has the given AccessLevel
            var functionConfiguration = builder.Function("HasAccessLevel");
            functionConfiguration.Parameter<int>("ID");
            functionConfiguration.Parameter<AccessLevel>("AccessLevel");
            functionConfiguration.Returns<bool>();

            builder.Namespace = typeof(Employee).Namespace;

            return builder.GetEdmModel();
        }
开发者ID:nickgoodrow,项目名称:ODataSamples,代码行数:21,代码来源:ODataModels.cs

示例15: Configuration

        public void Configuration(IAppBuilder builder)
        {
            var odataBuilder = new ODataConventionModelBuilder();
            odataBuilder.EntitySet<Player>("Players");
            var player = odataBuilder.EntityType<Player>();

            //collection function
            player.Collection.Function("TopPpg").ReturnsCollection<Player>();

            //entity function
            player.Function("PercentageOfAllGoals").Returns<double>();

            //service function
            var serviceFunc = odataBuilder.Function("TotalTeamPoints");
            serviceFunc.Returns<int>().Parameter<string>("team");
            serviceFunc.IncludeInServiceDocument = true;

            var edm = odataBuilder.GetEdmModel();

            var config = new HttpConfiguration();
            config.MapODataServiceRoute("Default OData", "odata", edm);
            builder.UseWebApi(config);
        }
开发者ID:diouf,项目名称:apress-recipes-webapi,代码行数:23,代码来源:Startup.cs


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