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

            FunctionConfiguration getEnum = builder.Function("GetEnum");

            getEnum.Parameter <SimpleEnum>("simpleEnum");
            getEnum.Returns <SimpleEnum>();

            FunctionConfiguration getFlagsEnum = builder.Function("GetFlagsEnum");

            getFlagsEnum.Parameter <FlagsEnum>("flagsEnum");
            getFlagsEnum.Returns <FlagsEnum>();

            FunctionConfiguration function = builder.Function("GetNullableFlagsEnum").Returns <bool>();

            function.Parameter <FlagsEnum?>("flagsEnum");

            return(builder.GetEdmModel());
        }
Exemple #2
0
        private IEdmModel GetEdmModel(HttpConfiguration configuration)
        {
            ODataConventionModelBuilder builder = ODataModelBuilderMocks.GetModelBuilderMock <ODataConventionModelBuilder>(configuration);

            builder.EntitySet <ConventionCustomer>("ConventionCustomers");
            builder.EntitySet <ConventionOrder>("ConventionOrders");
            builder.ComplexType <ConventionPerson>();
            builder.EntityType <ConventionCustomer>().ComplexProperty <ConventionAddress>(c => c.Address);

            // Top level action import
            ActionConfiguration createConventionCustomerById = builder.Action("CreateConventionCustomerById");

            createConventionCustomerById.Parameter <int>("ID");
            createConventionCustomerById.ReturnsFromEntitySet <ConventionCustomer>("ConventionCustomers");

            // Top level action import without parameter and with a collection of primitive return type
            ActionConfiguration topCollectionPrimitiveAction = builder.Action("CreateCollectionMessages");

            topCollectionPrimitiveAction.ReturnsCollection <string>();

            // Top level function import
            FunctionConfiguration getAllCustomers = builder.Function("GetAllConventionCustomers");

            getAllCustomers.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");

            // Top level function import with one parameter
            FunctionConfiguration getCustomersById = builder.Function("GetConventionCustomerById");

            getCustomersById.IsComposable = true;
            getCustomersById.Parameter <int>("CustomerId");
            getCustomersById.ReturnsFromEntitySet <ConventionCustomer>("ConventionCustomers");

            // Top level function import with two parameters
            FunctionConfiguration getOrder = builder.Function("GetConventionOrderByCustomerIdAndOrderName");

            getOrder.Parameter <int>("CustomerId");
            getOrder.Parameter <string>("OrderName");
            getOrder.ReturnsFromEntitySet <ConventionOrder>("ConventionOrders");

            return(builder.GetEdmModel());
        }
Exemple #3
0
            public static IEdmModel CreateModel()
            {
                var modelBuilder = new ODataConventionModelBuilder();

                modelBuilder.EnableLowerCamelCase();

                #region ENTITY TYPE

                var searchEntity = modelBuilder.EntityType <SearchViewModel>();
                searchEntity.Name      = Camelize(searchEntity.Name);
                searchEntity.Namespace = "search";
                searchEntity.HasKey(entity => entity.Count);

                #endregion

                #region COMPLEX TYPE

                modelBuilder.ComplexType <SearchResultViewModel>();

                #endregion

                #region ENITY SET

                modelBuilder.EntitySet <SearchViewModel>("search");

                #endregion

                #region FUNCTIONS

                FunctionConfiguration frontiersResult = modelBuilder.EntityType <SearchViewModel>().Collection.Function("frontiers");
                frontiersResult.Parameter <string>("type");
                frontiersResult.Namespace = GET_FUNCTION_NAMESPACE;
                frontiersResult.ReturnsFromEntitySet <SearchViewModel>("search");
                frontiersResult.Namespace = GET_FUNCTION_NAMESPACE;

                #endregion


                return(modelBuilder.GetEdmModel());
            }
Exemple #4
0
        private static void MapCommonOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <DocumentModel>("Documents")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <Core.Models.Workflows.Parameters.MetadataModel>("MetadataModel")
            .EntityType.HasKey(p => new { p.KeyName, p.Value });

            builder
            .EntitySet <CategoryModel>("Categories")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <ContainerModel>("Containers")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <GenericDocumentUnitModel>("GenericDocumentUnits")
            .EntityType.HasKey(p => p.Id);

            #region [ Functions ]

            FunctionConfiguration getProtocolDocumentsFunc = builder
                                                             .EntityType <DocumentModel>().Collection
                                                             .Function("GetDocuments");
            getProtocolDocumentsFunc.Namespace = "DocumentUnitService";
            getProtocolDocumentsFunc.ReturnsCollectionFromEntitySet <DocumentModel>("DocumentUnits");
            getProtocolDocumentsFunc.Parameter <Guid>("uniqueId");
            getProtocolDocumentsFunc.Parameter <Guid?>("workflowArchiveChainId");

            FunctionConfiguration getActivityDocuments = builder
                                                         .EntityType <DocumentModel>().Collection
                                                         .Function("GetDocumentsByArchiveChain");
            getActivityDocuments.Namespace = "DocumentUnitService";
            getActivityDocuments.ReturnsCollectionFromEntitySet <DocumentModel>("DocumentUnits");
            getActivityDocuments.Parameter <Guid>("idArchiveChain");
            #endregion
        }
Exemple #5
0
        public void WhenFunctionLinksNotManuallyConfigured_ConventionBasedBuilderUsesConventions()
        {
            // Arrange
            string            uriTemplate         = "http://server/Movies({0})/Default.Watch(param=@param)";
            Uri               expectedUri         = new Uri(string.Format(uriTemplate, 1));
            ODataModelBuilder builder             = ODataConventionModelBuilderFactory.Create();
            EntityTypeConfiguration <Movie> movie = builder.EntitySet <Movie>("Movies").EntityType;
            FunctionConfiguration           watch = movie.Function("Watch").Returns <int>();

            watch.Parameter <string>("param");
            IEdmModel model = builder.GetEdmModel();

            var    configuration = RoutingConfigurationFactory.Create();
            string routeName     = "Route";

            configuration.MapODataServiceRoute(routeName, null, model);

            var request = RequestFactory.Create(HttpMethod.Get, "http://server/Movies", configuration, routeName);

            // Act
            IEdmEntityType         movieType         = model.SchemaElements.OfType <IEdmEntityType>().SingleOrDefault();
            IEdmEntityContainer    container         = model.SchemaElements.OfType <IEdmEntityContainer>().SingleOrDefault();
            IEdmFunction           watchFunction     = Assert.Single(model.SchemaElements.OfType <IEdmFunction>()); // Guard
            IEdmEntitySet          entitySet         = container.EntitySets().SingleOrDefault();
            ODataSerializerContext serializerContext = ODataSerializerContextFactory.Create(model, entitySet, request);

            ResourceContext context = new ResourceContext(serializerContext, movieType.AsReference(), new Movie {
                ID = 1, Name = "Avatar"
            });
            OperationLinkBuilder functionLinkBuilder = model.GetAnnotationValue <OperationLinkBuilder>(watchFunction);

            //Assert
            Assert.Equal(expectedUri, watch.GetFunctionLink()(context));
            Assert.NotNull(functionLinkBuilder);
            Assert.Equal(expectedUri, functionLinkBuilder.BuildLink(context));
        }
Exemple #6
0
        public void CanCreateEdmModel_ForBindableFunction_WithSupportedParameterType()
        {
            // Arrange
            ODataModelBuilder builder = new ODataModelBuilder();
            EntityTypeConfiguration <Customer> customer = builder.EntityType <Customer>();

            customer.HasKey(c => c.CustomerId);
            customer.Property(c => c.Name);

            // Act
            FunctionConfiguration functionBuilder = customer.Function("FunctionName");

            functionBuilder.Parameter <int>("primitive");
            functionBuilder.CollectionParameter <int>("collectionPrimitive");

            functionBuilder.Parameter <bool?>("nullablePrimitive");
            functionBuilder.CollectionParameter <bool?>("nullableCollectionPrimitive");

            functionBuilder.Parameter <Color>("enum");
            functionBuilder.CollectionParameter <Color>("collectionEnum");

            functionBuilder.Parameter <Color?>("nullableEnum");
            functionBuilder.CollectionParameter <Color?>("nullableCollectionEnum");

            functionBuilder.Parameter <Address>("complex");
            functionBuilder.CollectionParameter <Address>("collectionComplex");

            functionBuilder.EntityParameter <Customer>("entity");
            functionBuilder.CollectionEntityParameter <Customer>("collectionEntity");

            functionBuilder.Returns <bool>();

            IEdmModel model = builder.GetEdmModel();

            // Assert
            Assert.Single(model.SchemaElements.OfType <IEdmFunction>());
            IEdmFunction function = Assert.Single(model.SchemaElements.OfType <IEdmFunction>());

            Assert.False(function.IsComposable);
            Assert.True(function.IsBound);
            Assert.Equal("FunctionName", function.Name);
            Assert.NotNull(function.ReturnType);

            Assert.Equal(13, function.Parameters.Count());

            function.AssertHasParameter(model, BindingParameterConfiguration.DefaultBindingParameterName, typeof(Customer), true);

            function.AssertHasParameter(model, parameterName: "primitive", parameterType: typeof(int), isNullable: false);
            function.AssertHasParameter(model, parameterName: "collectionPrimitive", parameterType: typeof(IList <int>), isNullable: false);

            function.AssertHasParameter(model, parameterName: "nullablePrimitive", parameterType: typeof(bool?), isNullable: true);
            function.AssertHasParameter(model, parameterName: "nullableCollectionPrimitive", parameterType: typeof(IList <bool?>), isNullable: true);

            function.AssertHasParameter(model, parameterName: "enum", parameterType: typeof(Color), isNullable: false);
            function.AssertHasParameter(model, parameterName: "collectionEnum", parameterType: typeof(IList <Color>), isNullable: false);

            function.AssertHasParameter(model, parameterName: "nullableEnum", parameterType: typeof(Color?), isNullable: true);
            function.AssertHasParameter(model, parameterName: "nullableCollectionEnum", parameterType: typeof(IList <Color?>), isNullable: true);

            function.AssertHasParameter(model, parameterName: "complex", parameterType: typeof(Address), isNullable: true);
            function.AssertHasParameter(model, parameterName: "collectionComplex", parameterType: typeof(IList <Address>), isNullable: true);

            function.AssertHasParameter(model, parameterName: "entity", parameterType: typeof(Customer), isNullable: true);
            function.AssertHasParameter(model, parameterName: "collectionEntity", parameterType: typeof(IList <Customer>), isNullable: true);
        }
        public static IEdmModel GetModel()
        {
            HttpConfiguration configuration = new HttpConfiguration();

            configuration.Services.Replace(typeof(IAssembliesResolver), new TestAssemblyResolver());
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder(configuration);

            builder.EntitySet <RoutingCustomer>("RoutingCustomers");
            builder.EntitySet <Product>("Products");
            builder.EntitySet <SalesPerson>("SalesPeople");
            builder.EntitySet <EmailAddress>("EmailAddresses");
            builder.EntitySet <üCategory>("üCategories");
            builder.EntitySet <EnumCustomer>("EnumCustomers");
            builder.Singleton <RoutingCustomer>("VipCustomer");
            builder.Singleton <Product>("MyProduct");
            builder.EntitySet <DateTimeOffsetKeyCustomer>("DateTimeOffsetKeyCustomers");
            builder.ComplexType <Dog>();
            builder.ComplexType <Cat>();

            ActionConfiguration getRoutingCustomerById = builder.Action("GetRoutingCustomerById");

            getRoutingCustomerById.Parameter <int>("RoutingCustomerId");
            getRoutingCustomerById.ReturnsFromEntitySet <RoutingCustomer>("RoutingCustomers");

            ActionConfiguration getSalesPersonById = builder.Action("GetSalesPersonById");

            getSalesPersonById.Parameter <int>("salesPersonId");
            getSalesPersonById.ReturnsFromEntitySet <SalesPerson>("SalesPeople");

            ActionConfiguration getAllVIPs = builder.Action("GetAllVIPs");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getAllVIPs, "RoutingCustomers");

            builder.EntityType <RoutingCustomer>().ComplexProperty <Address>(c => c.Address);
            builder.EntityType <RoutingCustomer>().Action("GetRelatedRoutingCustomers").ReturnsCollectionFromEntitySet <RoutingCustomer>("RoutingCustomers");

            ActionConfiguration getBestRelatedRoutingCustomer = builder.EntityType <RoutingCustomer>().Action("GetBestRelatedRoutingCustomer");

            ActionReturnsFromEntitySet <VIP>(builder, getBestRelatedRoutingCustomer, "RoutingCustomers");

            ActionConfiguration getVIPS = builder.EntityType <RoutingCustomer>().Collection.Action("GetVIPs");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getVIPS, "RoutingCustomers");

            builder.EntityType <RoutingCustomer>().Collection.Action("GetProducts").ReturnsCollectionFromEntitySet <Product>("Products");
            builder.EntityType <VIP>().Action("GetSalesPerson").ReturnsFromEntitySet <SalesPerson>("SalesPeople");
            builder.EntityType <VIP>().Collection.Action("GetSalesPeople").ReturnsCollectionFromEntitySet <SalesPerson>("SalesPeople");

            ActionConfiguration getMostProfitable = builder.EntityType <VIP>().Collection.Action("GetMostProfitable");

            ActionReturnsFromEntitySet <VIP>(builder, getMostProfitable, "RoutingCustomers");

            ActionConfiguration getVIPRoutingCustomers = builder.EntityType <SalesPerson>().Action("GetVIPRoutingCustomers");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getVIPRoutingCustomers, "RoutingCustomers");

            ActionConfiguration getVIPRoutingCustomersOnCollection = builder.EntityType <SalesPerson>().Collection.Action("GetVIPRoutingCustomers");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getVIPRoutingCustomersOnCollection, "RoutingCustomers");

            builder.EntityType <VIP>().HasRequired(v => v.RelationshipManager);
            builder.EntityType <ImportantProduct>().HasRequired(ip => ip.LeadSalesPerson);

            // function bound to an entity
            FunctionConfiguration topProductId = builder.EntityType <Product>().Function("TopProductId");

            topProductId.Returns <int>();

            FunctionConfiguration topProductIdByCity = builder.EntityType <Product>().Function("TopProductIdByCity");

            topProductIdByCity.Parameter <string>("city");
            topProductIdByCity.Returns <string>();

            FunctionConfiguration topProductIdByCityAndModel = builder.EntityType <Product>().Function("TopProductIdByCityAndModel");

            topProductIdByCityAndModel.Parameter <string>("city");
            topProductIdByCityAndModel.Parameter <int>("model");
            topProductIdByCityAndModel.Returns <string>();

            // function bound to a collection of entities
            FunctionConfiguration topProductOfAll = builder.EntityType <Product>().Collection.Function("TopProductOfAll");

            topProductOfAll.Returns <string>();

            FunctionConfiguration topProductOfAllByCity = builder.EntityType <Product>().Collection.Function("TopProductOfAllByCity");

            topProductOfAllByCity.Parameter <string>("city");
            topProductOfAllByCity.Returns <string>();

            FunctionConfiguration topProductOfAllByCityAndModel = builder.EntityType <Product>().Collection.Function("TopProductOfAllByCityAndModel");

            topProductOfAllByCityAndModel.Parameter <string>("city");
            topProductOfAllByCityAndModel.Parameter <int>("model");
            topProductOfAllByCityAndModel.Returns <string>();

            // Function bound to the base entity type and derived entity type
            builder.EntityType <RoutingCustomer>().Function("GetOrdersCount").Returns <string>();
            builder.EntityType <VIP>().Function("GetOrdersCount").Returns <string>();

            // Overloaded function only bound to the base entity type with one paramter
            var getOrderCount = builder.EntityType <RoutingCustomer>().Function("GetOrdersCount");

            getOrderCount.Parameter <int>("factor");
            getOrderCount.Returns <string>();

            // Function only bound to the derived entity type
            builder.EntityType <SpecialVIP>().Function("GetSpecialGuid").Returns <string>();

            // Function bound to the collection of the base and the derived entity type
            builder.EntityType <RoutingCustomer>().Collection.Function("GetAllEmployees").Returns <string>();
            builder.EntityType <VIP>().Collection.Function("GetAllEmployees").Returns <string>();

            // Bound function with enum type parameters
            var boundFunction = builder.EntityType <RoutingCustomer>().Collection.Function("BoundFuncWithEnumParameters");

            boundFunction.Parameter <SimpleEnum>("SimpleEnum");
            boundFunction.Parameter <FlagsEnum>("FlagsEnum");
            boundFunction.Returns <string>();

            // Bound function with enum type parameter for attribute routing
            var boundFunctionForAttributeRouting = builder.EntityType <RoutingCustomer>().Collection
                                                   .Function("BoundFuncWithEnumParameterForAttributeRouting");

            boundFunctionForAttributeRouting.Parameter <SimpleEnum>("SimpleEnum");
            boundFunctionForAttributeRouting.Returns <string>();

            // Unbound function with enum type parameters
            var function = builder.Function("UnboundFuncWithEnumParameters");

            function.Parameter <LongEnum>("LongEnum");
            function.Parameter <FlagsEnum>("FlagsEnum");
            function.Returns <string>();

            // Unbound function
            builder.Function("UnboundFunction").ReturnsCollection <int>().IsComposable = true;

            // Action only bound to the derived entity type
            builder.EntityType <SpecialVIP>().Action("ActionBoundToSpecialVIP");

            // Action only bound to the derived entity type
            builder.EntityType <SpecialVIP>().Collection.Action("ActionBoundToSpecialVIPs");

            // Function only bound to the base entity collection type
            builder.EntityType <RoutingCustomer>().Collection.Function("FunctionBoundToRoutingCustomers").Returns <int>();

            // Function only bound to the derived entity collection type
            builder.EntityType <VIP>().Collection.Function("FunctionBoundToVIPs").Returns <int>();

            // Bound function with multiple parameters
            var functionBoundToProductWithMultipleParamters = builder.EntityType <Product>().Function("FunctionBoundToProductWithMultipleParamters");

            functionBoundToProductWithMultipleParamters.Parameter <int>("P1");
            functionBoundToProductWithMultipleParamters.Parameter <int>("P2");
            functionBoundToProductWithMultipleParamters.Parameter <string>("P3");
            functionBoundToProductWithMultipleParamters.Returns <int>();

            // Overloaded bound function with no parameter
            builder.EntityType <Product>().Function("FunctionBoundToProduct").Returns <int>();

            // Overloaded bound function with one parameter
            builder.EntityType <Product>().Function("FunctionBoundToProduct").Returns <int>().Parameter <int>("P1");

            // Overloaded bound function with multiple parameters
            var functionBoundToProduct = builder.EntityType <Product>().Function("FunctionBoundToProduct").Returns <int>();

            functionBoundToProduct.Parameter <int>("P1");
            functionBoundToProduct.Parameter <int>("P2");
            functionBoundToProduct.Parameter <string>("P3");

            // Unbound function with one parameter
            var unboundFunctionWithOneParamters = builder.Function("UnboundFunctionWithOneParamters");

            unboundFunctionWithOneParamters.Parameter <int>("P1");
            unboundFunctionWithOneParamters.ReturnsFromEntitySet <RoutingCustomer>("RoutingCustomers");
            unboundFunctionWithOneParamters.IsComposable = true;

            // Unbound function with multiple parameters
            var functionWithMultipleParamters = builder.Function("UnboundFunctionWithMultipleParamters");

            functionWithMultipleParamters.Parameter <int>("P1");
            functionWithMultipleParamters.Parameter <int>("P2");
            functionWithMultipleParamters.Parameter <string>("P3");
            functionWithMultipleParamters.Returns <int>();

            // Overloaded unbound function with no parameter
            builder.Function("OverloadUnboundFunction").Returns <int>();

            // Overloaded unbound function with one parameter
            builder.Function("OverloadUnboundFunction").Returns <int>().Parameter <int>("P1");

            // Overloaded unbound function with multiple parameters
            var overloadUnboundFunction = builder.Function("OverloadUnboundFunction").Returns <int>();

            overloadUnboundFunction.Parameter <int>("P1");
            overloadUnboundFunction.Parameter <int>("P2");
            overloadUnboundFunction.Parameter <string>("P3");

            return(builder.GetEdmModel());
        }
Exemple #8
0
        private static IEdmModel GetEdmModel(IServiceProvider serviceProvider)
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder(serviceProvider);

            builder.EntitySet <Address>("Address")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <AddressType>("AddressType")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <BusinessEntity>("BusinessEntity")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();
            builder.EntitySet <BusinessEntityAddress>("BusinessEntityAddress")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <BusinessEntityContact>("BusinessEntityContact")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <ContactType>("ContactType")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <CountryRegion>("CountryRegion")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <EmailAddress>("EmailAddress")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <Password>("Password")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <Person>("Person")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();
            builder.EntitySet <PersonPhone>("PersonPhone")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <PhoneNumberType>("PhoneNumberType")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <StateProvince>("StateProvince")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            builder.EntitySet <EntityWithEnum>("EntityWithEnum")
            .EntityType
            .Filter()
            .Count()
            .Expand()
            .OrderBy()
            .Page()
            .Select();

            EntitySetConfiguration <ContactType> contactType = builder.EntitySet <ContactType>("ContactType");
            var actionY = contactType.EntityType.Action("ChangePersonStatus");

            actionY.Parameter <string>("Level");
            actionY.Returns <bool>();

            var changePersonStatusAction = contactType.EntityType.Collection.Action("ChangePersonStatus");

            changePersonStatusAction.Parameter <string>("Level");
            changePersonStatusAction.Returns <bool>();

            EntitySetConfiguration <Person> persons         = builder.EntitySet <Person>("Person");
            FunctionConfiguration           myFirstFunction = persons.EntityType.Collection.Function("MyFirstFunction");

            myFirstFunction.ReturnsCollectionFromEntitySet <Person>("Person");

            EntitySetConfiguration <EntityWithEnum> entitesWithEnum = builder.EntitySet <EntityWithEnum>("EntityWithEnum");
            FunctionConfiguration functionEntitesWithEnum           = entitesWithEnum.EntityType.Collection.Function("PersonSearchPerPhoneType");

            functionEntitesWithEnum.Parameter <PhoneNumberTypeEnum>("PhoneNumberTypeEnum");
            functionEntitesWithEnum.ReturnsCollectionFromEntitySet <EntityWithEnum>("EntityWithEnum");

            return(builder.GetEdmModel());
        }
        public static IEdmModel GetEdmModel(ODataConventionModelBuilder builder)
        {
            builder.EntitySet <ConventionCustomer>("ConventionCustomers");
            builder.EntitySet <ConventionOrder>("ConventionOrders");

            EnumTypeConfiguration <ConventionGender> enumType = builder.EnumType <ConventionGender>();

            enumType.Member(ConventionGender.Female);
            enumType.Member(ConventionGender.Male);
            #region functions

            FunctionConfiguration getAllCustomers = builder.Function("GetAllConventionCustomers");
            getAllCustomers.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");
            getAllCustomers.IsComposable = true;

            // Return all the customers whose name contains CustomerName
            FunctionConfiguration getAllCustomersOverload = builder.Function("GetAllConventionCustomers");
            getAllCustomersOverload.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");
            getAllCustomersOverload.Parameter <string>("CustomerName");
            getAllCustomersOverload.IsComposable = true;

            FunctionConfiguration getCustomersById = builder.Function("GetConventionCustomerById");
            getCustomersById.Parameter <int>("CustomerId");
            getCustomersById.ReturnsFromEntitySet <ConventionCustomer>("ConventionCustomers");
            getCustomersById.IsComposable = true;

            FunctionConfiguration getOrder = builder.Function("GetConventionOrderByCustomerIdAndOrderName");
            getOrder.Parameter <int>("CustomerId");
            getOrder.Parameter <string>("OrderName");
            getOrder.ReturnsFromEntitySet <ConventionOrder>("ConventionOrders");

            FunctionConfiguration getCustomerNameById = builder.Function("GetConventionCustomerNameById");
            getCustomerNameById.Parameter <int>("CustomerId");
            getCustomerNameById.Returns <string>();

            FunctionConfiguration getDefinedGenders = builder.Function("GetDefinedGenders");
            getDefinedGenders.ReturnsCollection <ConventionGender>()
            .IsComposable = true;

            FunctionConfiguration function = builder.Function("AdvancedFunction").Returns <bool>();
            function.CollectionParameter <int>("nums");
            function.CollectionParameter <ConventionGender>("genders");
            function.Parameter <ConventionAddress>("location");
            function.CollectionParameter <ConventionAddress>("addresses");
            function.EntityParameter <ConventionCustomer>("customer");
            function.CollectionEntityParameter <ConventionCustomer>("customers");

            #endregion

            #region actions

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

            // bug: error message:  non-binding parameter type must be either Primitive, Complex, Collection of Primitive or a Collection of Complex.

            /*
             * ActionConfiguration createCustomer = builder.Action("CreateCustomer");
             * createCustomer.Parameter<ConventionCustomer>("Customer");
             * createCustomer.ReturnsFromEntitySet<ConventionCustomer>("ConventionCustomers");
             */

            ActionConfiguration udpateAddress = builder.Action("UpdateAddress");
            udpateAddress.Parameter <ConventionAddress>("Address");
            udpateAddress.Parameter <int>("ID");
            udpateAddress.ReturnsCollectionFromEntitySet <ConventionCustomer>("ConventionCustomers");

            ActionConfiguration action = builder.Action("AdvancedAction");
            action.CollectionParameter <int>("nums");
            action.CollectionParameter <ConventionGender>("genders");
            action.Parameter <ConventionAddress>("location");
            action.CollectionParameter <ConventionAddress>("addresses");
            action.EntityParameter <ConventionCustomer>("customer");
            action.CollectionEntityParameter <ConventionCustomer>("customers");

            #endregion

            var schemaNamespace = typeof(ConventionCustomer).Namespace;

            builder.Namespace = schemaNamespace;

            var edmModel  = builder.GetEdmModel();
            var container = edmModel.EntityContainer as EdmEntityContainer;

            #region function imports

            var entitySet = container.FindEntitySet("ConventionCustomers");
            var getCustomersByIdOfEdmFunction = edmModel.FindDeclaredOperations(schemaNamespace + ".GetConventionCustomerById").First() as EdmFunction;
            container.AddFunctionImport("GetConventionCustomerByIdImport", getCustomersByIdOfEdmFunction, new EdmPathExpression(entitySet.Name));

            var functionsOfGetAllConventionCustomers   = edmModel.FindDeclaredOperations(schemaNamespace + ".GetAllConventionCustomers");
            var getAllConventionCustomersOfEdmFunction = functionsOfGetAllConventionCustomers.FirstOrDefault(f => f.Parameters.Count() == 0) as EdmFunction;
            container.AddFunctionImport("GetAllConventionCustomersImport", getAllConventionCustomersOfEdmFunction, new EdmPathExpression(entitySet.Name));

            // TODO delete this overload after bug 1640 is fixed: It can not find the correct overload function if the the function is exposed as a function import.
            var getAllConventionCustomersOverloadOfEdmFunction = functionsOfGetAllConventionCustomers.FirstOrDefault(f => f.Parameters.Count() > 0) as EdmFunction;
            container.AddFunctionImport("GetAllConventionCustomersImport", getAllConventionCustomersOverloadOfEdmFunction, new EdmPathExpression(entitySet.Name));

            var entitySet1 = container.FindEntitySet("ConventionOrders");
            var GetConventionOrderByCustomerIdAndOrderNameOfEdmFunction = edmModel.FindDeclaredOperations(schemaNamespace + ".GetConventionOrderByCustomerIdAndOrderName").First() as EdmFunction;
            container.AddFunctionImport("GetConventionOrderByCustomerIdAndOrderNameImport", GetConventionOrderByCustomerIdAndOrderNameOfEdmFunction, new EdmPathExpression(entitySet1.Name));

            var getConventionCustomerNameByIdOfEdmFunction = edmModel.FindDeclaredOperations(schemaNamespace + ".GetConventionCustomerNameById").First() as EdmFunction;
            container.AddFunctionImport("GetConventionCustomerNameByIdImport", getConventionCustomerNameByIdOfEdmFunction, null);

            #endregion

            #region action imports

            var resetDataSourceOfEdmAction = edmModel.FindDeclaredOperations(schemaNamespace + ".ResetDataSource").FirstOrDefault() as EdmAction;
            container.AddActionImport("ResetDataSourceImport", resetDataSourceOfEdmAction);

            // TODO: it is a potential issue that entity can not be used as an un-bound parameter.

            /*
             * var createCustomerOfEdmAction = edmModel.FindDeclaredOperations(schemaNamespace + ".CreateCustomer").FirstOrDefault() as EdmAction;
             * container.AddActionImport("CreateCustomerImport", createCustomerOfEdmAction);
             */
            var updateAddressOfEdmAction = edmModel.FindDeclaredOperations(schemaNamespace + ".UpdateAddress").FirstOrDefault() as EdmAction;
            container.AddActionImport("UpdateAddressImport", updateAddressOfEdmAction, new EdmPathExpression(entitySet.Name));

            #endregion

            return(edmModel);
        }
        // Builds the EDM model for the OData service, including the OData action definitions.
        private static IEdmModel GetEdmModel()
        {
            var modelBuilder = new ODataConventionModelBuilder();

            modelBuilder.EntitySet <Vedio>("Vedios");

            ActionConfiguration returnAcAction = modelBuilder.Action("ReturnAc");

            returnAcAction.Parameter <int>("key");
            returnAcAction.ReturnsFromEntitySet <Vedio>("Vedios");

            FunctionConfiguration checkOutAction = modelBuilder.Function("CheckOut");

            checkOutAction.Parameter <int>("key");
            checkOutAction.ReturnsFromEntitySet <Vedio>("Vedios");

            ActionConfiguration createMovieAction = modelBuilder.Action("CreateVedio");

            createMovieAction.Parameter <Vedio>("vedio");
            createMovieAction.ReturnsFromEntitySet <Vedio>("Vedios");

            ActionConfiguration ListAcAction = modelBuilder.Action("ListAc");

            ListAcAction.Parameter <Window>("windows");
            ListAcAction.Returns <int>();

            ActionConfiguration checkOutManyAction = modelBuilder.Action("CheckOutMany");

            checkOutManyAction.CollectionParameter <int>("MovieIDs");
            checkOutManyAction.ReturnsCollectionFromEntitySet <Vedio>("Vedios");

            //######################################################################################################//
            modelBuilder.EntitySet <QueryResult>("QueryResults");

            FunctionConfiguration GetRunningTasks = modelBuilder.Function("GetRunningTasks");

            GetRunningTasks.Parameter <QueryEntity>("query");
            GetRunningTasks.ReturnsCollectionFromEntitySet <QueryResult>("QueryResults");

            FunctionConfiguration GetReadyTasks = modelBuilder.Function("GetReadyTasks");

            GetReadyTasks.Parameter <QueryEntity>("query");
            GetReadyTasks.ReturnsCollectionFromEntitySet <QueryResult>("QueryResults");

            //######################################################################################################//

            ActionConfiguration StartProcess = modelBuilder.Action("StartProcess");

            StartProcess.Parameter <WfRunner>("WfRunner");
            StartProcess.Returns <int>();

            ActionConfiguration RunProcess = modelBuilder.Action("RunProcess");

            RunProcess.Parameter <WfRunner>("WfRunner");
            RunProcess.Returns <string>();

            ActionConfiguration WithdrawProcess = modelBuilder.Action("WithdrawProcess");

            WithdrawProcess.Parameter <WfRunner>("WfRunner");
            WithdrawProcess.Returns <string>();

            ActionConfiguration SendBackProcess = modelBuilder.Action("SendBackProcess");

            SendBackProcess.Parameter <WfRunner>("WfRunner");
            SendBackProcess.Returns <string>();

            ActionConfiguration JumpProcess = modelBuilder.Action("JumpProcess");

            JumpProcess.Parameter <WfRunner>("WfRunner");
            JumpProcess.Returns <string>();

            ActionConfiguration ReverseProcess = modelBuilder.Action("ReverseProcess");

            ReverseProcess.Parameter <WfRunner>("WfRunner");
            ReverseProcess.Returns <string>();

            ActionConfiguration DiscardProcess = modelBuilder.Action("DiscardProcess");

            DiscardProcess.Parameter <WfRunner>("WfRunner");
            DiscardProcess.Returns <string>();

            modelBuilder.Namespace = "WF";
            return(modelBuilder.GetEdmModel());
        }
Exemple #11
0
        public static IEdmModel GetModel()
        {
            var configuration = RoutingConfigurationFactory.CreateWithTypes();
            ODataConventionModelBuilder builder = ODataConventionModelBuilderFactory.Create(configuration);

            builder.EntitySet <RoutingCustomer>("RoutingCustomers");
            builder.EntitySet <Product>("Products");
            builder.EntitySet <SalesPerson>("SalesPeople");
            builder.EntitySet <EmailAddress>("EmailAddresses");
            builder.EntitySet <üCategory>("üCategories");
            builder.EntitySet <EnumCustomer>("EnumCustomers");
            builder.Singleton <RoutingCustomer>("VipCustomer");
            builder.Singleton <Product>("MyProduct");
            builder.EntitySet <DateTimeOffsetKeyCustomer>("DateTimeOffsetKeyCustomers");
            builder.EntitySet <Destination>("Destinations");
            builder.EntitySet <Incident>("Incidents");
            builder.ComplexType <Dog>();
            builder.ComplexType <Cat>();
            builder.EntityType <SpecialProduct>();
            builder.ComplexType <UsAddress>();

            ActionConfiguration getRoutingCustomerById = builder.Action("GetRoutingCustomerById");

            getRoutingCustomerById.Parameter <int>("RoutingCustomerId");
            getRoutingCustomerById.ReturnsFromEntitySet <RoutingCustomer>("RoutingCustomers");

            ActionConfiguration getSalesPersonById = builder.Action("GetSalesPersonById");

            getSalesPersonById.Parameter <int>("salesPersonId");
            getSalesPersonById.ReturnsFromEntitySet <SalesPerson>("SalesPeople");

            ActionConfiguration getAllVIPs = builder.Action("GetAllVIPs");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getAllVIPs, "RoutingCustomers");

            builder.EntityType <RoutingCustomer>().ComplexProperty <Address>(c => c.Address);
            builder.EntityType <RoutingCustomer>().Action("GetRelatedRoutingCustomers").ReturnsCollectionFromEntitySet <RoutingCustomer>("RoutingCustomers");

            ActionConfiguration getBestRelatedRoutingCustomer = builder.EntityType <RoutingCustomer>().Action("GetBestRelatedRoutingCustomer");

            ActionReturnsFromEntitySet <VIP>(builder, getBestRelatedRoutingCustomer, "RoutingCustomers");

            ActionConfiguration getVIPS = builder.EntityType <RoutingCustomer>().Collection.Action("GetVIPs");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getVIPS, "RoutingCustomers");

            builder.EntityType <RoutingCustomer>().Collection.Action("GetProducts").ReturnsCollectionFromEntitySet <Product>("Products");
            builder.EntityType <VIP>().Action("GetSalesPerson").ReturnsFromEntitySet <SalesPerson>("SalesPeople");
            builder.EntityType <VIP>().Collection.Action("GetSalesPeople").ReturnsCollectionFromEntitySet <SalesPerson>("SalesPeople");

            ActionConfiguration getMostProfitable = builder.EntityType <VIP>().Collection.Action("GetMostProfitable");

            ActionReturnsFromEntitySet <VIP>(builder, getMostProfitable, "RoutingCustomers");

            ActionConfiguration getVIPRoutingCustomers = builder.EntityType <SalesPerson>().Action("GetVIPRoutingCustomers");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getVIPRoutingCustomers, "RoutingCustomers");

            ActionConfiguration getVIPRoutingCustomersOnCollection = builder.EntityType <SalesPerson>().Collection.Action("GetVIPRoutingCustomers");

            ActionReturnsCollectionFromEntitySet <VIP>(builder, getVIPRoutingCustomersOnCollection, "RoutingCustomers");

            builder.EntityType <VIP>().HasRequired(v => v.RelationshipManager);
            builder.EntityType <ImportantProduct>().HasRequired(ip => ip.LeadSalesPerson);

            // function bound to an entity
            FunctionConfiguration topProductId = builder.EntityType <Product>().Function("TopProductId");

            topProductId.Returns <int>();

            FunctionConfiguration topProductIdByCity = builder.EntityType <Product>().Function("TopProductIdByCity");

            topProductIdByCity.Parameter <string>("city");
            topProductIdByCity.Returns <string>();

            FunctionConfiguration topProductIdByCityAndModel = builder.EntityType <Product>().Function("TopProductIdByCityAndModel");

            topProductIdByCityAndModel.Parameter <string>("city");
            topProductIdByCityAndModel.Parameter <int>("model");
            topProductIdByCityAndModel.Returns <string>();

            FunctionConfiguration optionFunctions = builder.EntityType <Product>().Collection.Function("GetCount").Returns <int>();

            optionFunctions.Parameter <double>("minSalary");
            optionFunctions.Parameter <double>("maxSalary").Optional();
            optionFunctions.Parameter <double>("aveSalary").Optional().HasDefaultValue("1200.99");

            // function bound to a collection of entities
            FunctionConfiguration topProductOfAll = builder.EntityType <Product>().Collection.Function("TopProductOfAll");

            topProductOfAll.Returns <string>();

            FunctionConfiguration topProductOfAllByCity = builder.EntityType <Product>().Collection.Function("TopProductOfAllByCity");

            topProductOfAllByCity.Parameter <string>("city");
            topProductOfAllByCity.Returns <string>();

            FunctionConfiguration copyProductByCity = builder.EntityType <Product>().Function("CopyProductByCity");

            copyProductByCity.Parameter <string>("city");
            copyProductByCity.Returns <string>();

            FunctionConfiguration topProductOfAllByCityAndModel = builder.EntityType <Product>().Collection.Function("TopProductOfAllByCityAndModel");

            topProductOfAllByCityAndModel.Parameter <string>("city");
            topProductOfAllByCityAndModel.Parameter <int>("model");
            topProductOfAllByCityAndModel.Returns <string>();

            // Function bound to the base entity type and derived entity type
            builder.EntityType <RoutingCustomer>().Function("GetOrdersCount").Returns <string>();
            builder.EntityType <VIP>().Function("GetOrdersCount").Returns <string>();

            // Overloaded function only bound to the base entity type with one paramter
            var getOrderCount = builder.EntityType <RoutingCustomer>().Function("GetOrdersCount");

            getOrderCount.Parameter <int>("factor");
            getOrderCount.Returns <string>();

            // Function only bound to the derived entity type
            builder.EntityType <SpecialVIP>().Function("GetSpecialGuid").Returns <string>();

            // Function bound to the collection of the base and the derived entity type
            builder.EntityType <RoutingCustomer>().Collection.Function("GetAllEmployees").Returns <string>();
            builder.EntityType <VIP>().Collection.Function("GetAllEmployees").Returns <string>();

            // Bound function with enum type parameters
            var boundFunction = builder.EntityType <RoutingCustomer>().Collection.Function("BoundFuncWithEnumParameters");

            boundFunction.Parameter <SimpleEnum>("SimpleEnum");
            boundFunction.Parameter <FlagsEnum>("FlagsEnum");
            boundFunction.Returns <string>();

            // Bound function with enum type parameter for attribute routing
            var boundFunctionForAttributeRouting = builder.EntityType <RoutingCustomer>().Collection
                                                   .Function("BoundFuncWithEnumParameterForAttributeRouting");

            boundFunctionForAttributeRouting.Parameter <SimpleEnum>("SimpleEnum");
            boundFunctionForAttributeRouting.Returns <string>();

            // Unbound function with enum type parameters
            var function = builder.Function("UnboundFuncWithEnumParameters");

            function.Parameter <LongEnum>("LongEnum");
            function.Parameter <FlagsEnum>("FlagsEnum");
            function.Returns <string>();

            // Unbound function
            builder.Function("UnboundFunction").ReturnsCollection <int>().IsComposable = true;

            // Action only bound to the derived entity type
            builder.EntityType <SpecialVIP>().Action("ActionBoundToSpecialVIP");

            // Action only bound to the derived entity type
            builder.EntityType <SpecialVIP>().Collection.Action("ActionBoundToSpecialVIPs");

            // Function only bound to the base entity collection type
            builder.EntityType <RoutingCustomer>().Collection.Function("FunctionBoundToRoutingCustomers").Returns <int>();

            // Function only bound to the derived entity collection type
            builder.EntityType <VIP>().Collection.Function("FunctionBoundToVIPs").Returns <int>();

            // Bound function with multiple parameters
            var functionBoundToProductWithMultipleParamters = builder.EntityType <Product>().Function("FunctionBoundToProductWithMultipleParamters");

            functionBoundToProductWithMultipleParamters.Parameter <int>("P1");
            functionBoundToProductWithMultipleParamters.Parameter <int>("P2");
            functionBoundToProductWithMultipleParamters.Parameter <string>("P3");
            functionBoundToProductWithMultipleParamters.Returns <int>();

            // Overloaded bound function with no parameter
            builder.EntityType <Product>().Function("FunctionBoundToProduct").Returns <int>();

            // Overloaded bound function with one parameter
            builder.EntityType <Product>().Function("FunctionBoundToProduct").Returns <int>().Parameter <int>("P1");

            // Overloaded bound function with multiple parameters
            var functionBoundToProduct = builder.EntityType <Product>().Function("FunctionBoundToProduct").Returns <int>();

            functionBoundToProduct.Parameter <int>("P1");
            functionBoundToProduct.Parameter <int>("P2");
            functionBoundToProduct.Parameter <string>("P3");

            // Unbound function with one parameter
            var unboundFunctionWithOneParamters = builder.Function("UnboundFunctionWithOneParamters");

            unboundFunctionWithOneParamters.Parameter <int>("P1");
            unboundFunctionWithOneParamters.ReturnsFromEntitySet <RoutingCustomer>("RoutingCustomers");
            unboundFunctionWithOneParamters.IsComposable = true;

            // Unbound function with multiple parameters
            var functionWithMultipleParamters = builder.Function("UnboundFunctionWithMultipleParamters");

            functionWithMultipleParamters.Parameter <int>("P1");
            functionWithMultipleParamters.Parameter <int>("P2");
            functionWithMultipleParamters.Parameter <string>("P3");
            functionWithMultipleParamters.Returns <int>();

            // Overloaded unbound function with no parameter
            builder.Function("OverloadUnboundFunction").Returns <int>();

            // Overloaded unbound function with one parameter
            builder.Function("OverloadUnboundFunction").Returns <int>().Parameter <int>("P1");

            // Overloaded unbound function with multiple parameters
            var overloadUnboundFunction = builder.Function("OverloadUnboundFunction").Returns <int>();

            overloadUnboundFunction.Parameter <int>("P1");
            overloadUnboundFunction.Parameter <int>("P2");
            overloadUnboundFunction.Parameter <string>("P3");

            var functionWithComplexTypeParameter =
                builder.EntityType <RoutingCustomer>().Function("CanMoveToAddress").Returns <bool>();

            functionWithComplexTypeParameter.Parameter <Address>("address");

            var functionWithCollectionOfComplexTypeParameter =
                builder.EntityType <RoutingCustomer>().Function("MoveToAddresses").Returns <bool>();

            functionWithCollectionOfComplexTypeParameter.CollectionParameter <Address>("addresses");

            var functionWithCollectionOfPrimitiveTypeParameter =
                builder.EntityType <RoutingCustomer>().Function("CollectionOfPrimitiveTypeFunction").Returns <bool>();

            functionWithCollectionOfPrimitiveTypeParameter.CollectionParameter <int>("intValues");

            var functionWithEntityTypeParameter =
                builder.EntityType <RoutingCustomer>().Function("EntityTypeFunction").Returns <bool>();

            functionWithEntityTypeParameter.EntityParameter <Product>("product");

            var functionWithCollectionEntityTypeParameter =
                builder.EntityType <RoutingCustomer>().Function("CollectionEntityTypeFunction").Returns <bool>();

            functionWithCollectionEntityTypeParameter.CollectionEntityParameter <Product>("products");

            return(builder.GetEdmModel());
        }
Exemple #12
0
        private static void MapProtocolOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <ProtocolModel>("Protocols")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <ProtocolModel>("ProtocolAuthorized")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <ProtocolContactModel>("ProtocolContacts")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <ProtocolSectorModel>("ProtocolSectors")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <ProtocolUserModel>("ProtocolUsers")
            .EntityType.HasKey(p => p.Id);

            #region [ Functions ]
            FunctionConfiguration getProtocolSummaryFunc = builder
                                                           .EntityType <ProtocolModel>().Collection
                                                           .Function("GetProtocolSummary");

            getProtocolSummaryFunc.Namespace = "ProtocolService";
            getProtocolSummaryFunc.ReturnsCollectionFromEntitySet <ProtocolModel>("Protocols");
            getProtocolSummaryFunc.Parameter <short>("year");
            getProtocolSummaryFunc.Parameter <int>("number");

            FunctionConfiguration getOutgoingPECCount = builder
                                                        .EntityType <ProtocolModel>().Collection
                                                        .Function("GetProtocolOutgoingPECCount")
                                                        .Returns <int>();

            getOutgoingPECCount.Namespace = "ProtocolService";
            getOutgoingPECCount.Parameter <short>("year");
            getOutgoingPECCount.Parameter <int>("number");

            FunctionConfiguration getIngoingPECCount = builder
                                                       .EntityType <ProtocolModel>().Collection
                                                       .Function("GetProtocolIngoingPECCount")
                                                       .Returns <int>();

            getIngoingPECCount.Namespace = "ProtocolService";
            getIngoingPECCount.Parameter <short>("year");
            getIngoingPECCount.Parameter <int>("number");

            FunctionConfiguration getProtocolSummaryNoAuthFunc = builder
                                                                 .EntityType <ProtocolModel>().Collection
                                                                 .Function("GetProtocolSummary");

            getProtocolSummaryNoAuthFunc.Namespace = "ProtocolAuthorizedService";
            getProtocolSummaryNoAuthFunc.ReturnsCollectionFromEntitySet <ProtocolModel>("Protocols");
            getProtocolSummaryNoAuthFunc.Parameter <Guid>("id");

            FunctionConfiguration getOutgoingPECCountNoAuth = builder
                                                              .EntityType <ProtocolModel>().Collection
                                                              .Function("GetProtocolOutgoingPECCount")
                                                              .Returns <int>();

            getOutgoingPECCountNoAuth.Namespace = "ProtocolAuthorizedService";
            getOutgoingPECCountNoAuth.Parameter <short>("year");
            getOutgoingPECCountNoAuth.Parameter <int>("number");

            FunctionConfiguration getIngoingPECCountNoAuth = builder
                                                             .EntityType <ProtocolModel>().Collection
                                                             .Function("GetProtocolIngoingPECCount")
                                                             .Returns <int>();

            getIngoingPECCountNoAuth.Namespace = "ProtocolAuthorizedService";
            getIngoingPECCountNoAuth.Parameter <short>("year");
            getIngoingPECCountNoAuth.Parameter <int>("number");

            FunctionConfiguration getUserAuthorized = builder
                                                      .EntityType <ProtocolModel>().Collection
                                                      .Function("GetUserAuthorizedProtocols")
                                                      .ReturnsCollectionFromEntitySet <ProtocolModel>("Protocol");

            getUserAuthorized.Namespace = "ProtocolAuthorizedService";
            getUserAuthorized.Parameter <int>("skip");
            getUserAuthorized.Parameter <int>("top");
            getUserAuthorized.Parameter <string>("subject");
            getUserAuthorized.Parameter <DateTimeOffset?>("dateFrom");
            getUserAuthorized.Parameter <DateTimeOffset?>("dateTo");
            getUserAuthorized.Parameter <string>("contact");

            FunctionConfiguration countUserAuthorized = builder
                                                        .EntityType <ProtocolModel>().Collection
                                                        .Function("GetUserAuthorizedProtocolsCount")
                                                        .Returns <int>();
            countUserAuthorized.Namespace = "ProtocolAuthorizedService";
            countUserAuthorized.Parameter <string>("subject");
            countUserAuthorized.Parameter <DateTimeOffset?>("dateFrom");
            countUserAuthorized.Parameter <DateTimeOffset?>("dateTo");
            countUserAuthorized.Parameter <string>("contact");

            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
Exemple #13
0
        private static void MapFascilceOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <FascicleModel>("Fascicles")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <FascicleContactModel>("FascicleContacts")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <GenericDocumentUnitModel>("FascicleDocumentUnits")
            .EntityType.HasKey(p => p.Id);

            builder
            .EntitySet <FascicleFolderTableValuedModel>("FascicleFolders")
            .EntityType.HasKey(p => p.IdFascicleFolder);

            #region [ Functions ]
            FunctionConfiguration getFascicleSummary = builder
                                                       .EntityType <FascicleModel>().Collection
                                                       .Function("GetFascicleSummary");

            getFascicleSummary.Namespace = "FascicleService";
            getFascicleSummary.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFascicleSummary.Parameter <Guid>("uniqueId");

            FunctionConfiguration getFascicleSummaryByYearAndNumber = builder
                                                                      .EntityType <FascicleModel>().Collection
                                                                      .Function("GetFascicleSummaryByYearAndNumber");

            getFascicleSummaryByYearAndNumber.Namespace = "FascicleService";
            getFascicleSummaryByYearAndNumber.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFascicleSummaryByYearAndNumber.Parameter <short>("year");
            getFascicleSummaryByYearAndNumber.Parameter <int>("number");
            getFascicleSummaryByYearAndNumber.Parameter <short>("code");

            FunctionConfiguration getFascicleSummaryByTitle = builder
                                                              .EntityType <FascicleModel>().Collection
                                                              .Function("GetFascicleSummaryByTitle");

            getFascicleSummaryByTitle.Namespace = "FascicleService";
            getFascicleSummaryByTitle.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFascicleSummaryByTitle.Parameter <string>("title");

            FunctionConfiguration getFascicleDocumentUnits = builder
                                                             .EntityType <FascicleModel>().Collection
                                                             .Function("GetFascicleDocumentUnits");

            getFascicleDocumentUnits.Namespace = "FascicleService";
            getFascicleDocumentUnits.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFascicleDocumentUnits.Parameter <Guid>("uniqueId");
            getFascicleDocumentUnits.Parameter <string>("filter");

            FunctionConfiguration getFascicleDocuments = builder
                                                         .EntityType <FascicleModel>().Collection
                                                         .Function("GetFascicleDocuments");

            getFascicleDocuments.Namespace = "FascicleService";
            getFascicleDocuments.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFascicleDocuments.Parameter <Guid>("uniqueId");

            FunctionConfiguration getNextFascicleFolders = builder
                                                           .EntityType <FascicleFolderTableValuedModel>().Collection
                                                           .Function("GetNextFascicleFolders");
            getNextFascicleFolders.Namespace = "FascicleService";
            getNextFascicleFolders.Parameter <Guid>("id");
            getNextFascicleFolders.ReturnsCollectionFromEntitySet <FascicleFolderTableValuedModel>("FascicleFolders");

            FunctionConfiguration getFascicleDocumentUnitFromFolder = builder
                                                                      .EntityType <FascicleFolderTableValuedModel>().Collection
                                                                      .Function("GetFascicleDocumentUnitFromFolder");
            getFascicleDocumentUnitFromFolder.Namespace = "FascicleService";
            getFascicleDocumentUnitFromFolder.Parameter <Guid>("id");
            getFascicleDocumentUnitFromFolder.ReturnsCollection <GenericDocumentUnitModel>();

            FunctionConfiguration getFascicleDocumentFromFolder = builder
                                                                  .EntityType <FascicleFolderTableValuedModel>().Collection
                                                                  .Function("GetFascicleDocumentFromFolder");
            getFascicleDocumentFromFolder.Namespace = "FascicleService";
            getFascicleDocumentFromFolder.Parameter <Guid>("id");
            getFascicleDocumentFromFolder.ReturnsCollection <FascicleDocumentModel>();

            FunctionConfiguration getFascicleFlatDocuments = builder
                                                             .EntityType <FascicleModel>().Collection
                                                             .Function("GetFascicleFlatDocuments");

            getFascicleFlatDocuments.Namespace = "FascicleService";
            getFascicleFlatDocuments.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFascicleFlatDocuments.Parameter <Guid>("uniqueId");

            FunctionConfiguration getFasciclesByMetadataIdentifier = builder
                                                                     .EntityType <FascicleModel>().Collection
                                                                     .Function("GetFasciclesByMetadataIdentifier");

            getFasciclesByMetadataIdentifier.Namespace = "FascicleService";
            getFasciclesByMetadataIdentifier.ReturnsCollectionFromEntitySet <FascicleModel>("Fascicles");
            getFasciclesByMetadataIdentifier.Parameter <string>("name");
            getFasciclesByMetadataIdentifier.Parameter <string>("identifier");

            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
Exemple #14
0
        private static void MapResolutionOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <ResolutionModel>("Resolution")
            .EntityType.HasKey(p => p.Id);

            #region [ Functions ]
            FunctionConfiguration getExecutiveResolutionsFunc = builder
                                                                .EntityType <ResolutionModel>().Collection
                                                                .Function("GetExecutiveResolutions");

            getExecutiveResolutionsFunc.Namespace = "ResolutionService";
            getExecutiveResolutionsFunc.ReturnsCollectionFromEntitySet <ResolutionModel>("Resolution");
            getExecutiveResolutionsFunc.Parameter <int>("skip");
            getExecutiveResolutionsFunc.Parameter <int>("top");
            getExecutiveResolutionsFunc.Parameter <ResolutionType>("type");
            getExecutiveResolutionsFunc.Parameter <short?>("year");
            getExecutiveResolutionsFunc.Parameter <int?>("number");
            getExecutiveResolutionsFunc.Parameter <string>("subject");
            getExecutiveResolutionsFunc.Parameter <string>("adoptionDate");
            getExecutiveResolutionsFunc.Parameter <string>("proposer");

            FunctionConfiguration getPublishedResolutionsFunc = builder
                                                                .EntityType <ResolutionModel>().Collection
                                                                .Function("GetPublishedResolutions");

            getPublishedResolutionsFunc.Namespace = "ResolutionService";
            getPublishedResolutionsFunc.ReturnsCollectionFromEntitySet <ResolutionModel>("Resolution");
            getPublishedResolutionsFunc.Parameter <int>("skip");
            getPublishedResolutionsFunc.Parameter <int>("top");
            getPublishedResolutionsFunc.Parameter <ResolutionType>("type");
            getPublishedResolutionsFunc.Parameter <short?>("year");
            getPublishedResolutionsFunc.Parameter <int?>("number");
            getPublishedResolutionsFunc.Parameter <string>("subject");
            getPublishedResolutionsFunc.Parameter <string>("adoptionDate");
            getPublishedResolutionsFunc.Parameter <string>("proposer");

            FunctionConfiguration getExecutiveReslCount = builder
                                                          .EntityType <ResolutionModel>().Collection
                                                          .Function("GetExecutiveResolutionsCount")
                                                          .Returns <int>();

            getExecutiveReslCount.Namespace = "ResolutionService";
            getExecutiveReslCount.Parameter <ResolutionType>("type");
            getExecutiveReslCount.Parameter <short?>("year");
            getExecutiveReslCount.Parameter <string>("subject");
            getExecutiveReslCount.Parameter <int?>("number");
            getExecutiveReslCount.Parameter <string>("adoptionDate");
            getExecutiveReslCount.Parameter <string>("proposer");

            FunctionConfiguration getPublishedReslCount = builder
                                                          .EntityType <ResolutionModel>().Collection
                                                          .Function("GetPublishedResolutionsCount")
                                                          .Returns <int>();

            getPublishedReslCount.Namespace = "ResolutionService";
            getPublishedReslCount.Parameter <ResolutionType>("type");
            getPublishedReslCount.Parameter <short?>("year");
            getPublishedReslCount.Parameter <int?>("number");
            getPublishedReslCount.Parameter <string>("subject");
            getPublishedReslCount.Parameter <string>("adoptionDate");
            getPublishedReslCount.Parameter <string>("proposer");

            FunctionConfiguration getOnlineResolutionsFunc = builder
                                                             .EntityType <ResolutionModel>().Collection
                                                             .Function("GetOnlinePublishedResolutions");

            getOnlineResolutionsFunc.Namespace = "ResolutionService";
            getOnlineResolutionsFunc.ReturnsCollectionFromEntitySet <ResolutionModel>("Resolution");
            getOnlineResolutionsFunc.Parameter <ResolutionType>("type");


            #endregion

            #region [ Navigation Properties ]

            #endregion
        }