Exemplo n.º 1
0
        public static IEdmModel GetEdmModel()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            var entityCollection = builder.EntitySet <DollarCountEntity>("DollarCountEntities").EntityType.Collection;

            // Add unbound functions that return collection.
            FunctionConfiguration function = builder.Function("UnboundFunctionReturnsPrimitveCollection");

            function.IsComposable = true;
            function.ReturnsCollection <int>();

            function = builder.Function("UnboundFunctionReturnsEnumCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DollarColor>();

            function = builder.Function("UnboundFunctionReturnsDateTimeOffsetCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DateTimeOffset>();

            function = builder.Function("UnboundFunctionReturnsDateCollection");
            function.IsComposable = true;
            function.ReturnsCollection <Date>();

            function = builder.Function("UnboundFunctionReturnsComplexCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DollarCountComplex>();

            function = builder.Function("UnboundFunctionReturnsEntityCollection");
            function.IsComposable = true;
            function.ReturnsCollectionFromEntitySet <DollarCountEntity>("DollarCountEntities");

            // Add bound functions that return collection.
            function = entityCollection.Function("BoundFunctionReturnsPrimitveCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DateTimeOffset>();

            function = entityCollection.Function("BoundFunctionReturnsEnumCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DollarColor>();

            function = entityCollection.Function("BoundFunctionReturnsDateTimeOffsetCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DateTimeOffset>();

            function = entityCollection.Function("BoundFunctionReturnsComplexCollection");
            function.IsComposable = true;
            function.ReturnsCollection <DollarCountComplex>();

            function = entityCollection.Function("BoundFunctionReturnsEntityCollection");
            function.IsComposable = true;
            function.ReturnsCollectionFromEntitySet <DollarCountEntity>("DollarCountEntities");

            return(builder.GetEdmModel());
        }
Exemplo n.º 2
0
        private static IEdmModel getEdmModel()
        {
            ODataConventionModelBuilder      modelBuilder    = new ODataConventionModelBuilder();
            EntitySetConfiguration <Person>  peopleEntitySet = modelBuilder.EntitySet <Person>("People");
            EntityTypeConfiguration <Person> personType      = peopleEntitySet.EntityType;

            personType.Ignore(p => p.CreatedTime);
            personType.Ignore(p => p.LastModifiedTime);

            EntitySetConfiguration <Account>  accountEntitySet = modelBuilder.EntitySet <Account>("Accounts");
            EntityTypeConfiguration <Account> accountType      = accountEntitySet.EntityType;

            accountType.Ignore(a => a.LastModifyTime);
            accountType.Ignore(a => a.CreateTime);

            FunctionConfiguration getPersonAndDescendants = modelBuilder.Function("GetPersonAndDescendants");

            getPersonAndDescendants.ReturnsFromEntitySet <Person>("People");
            getPersonAndDescendants.Parameter <long>("Id");          // The id of the root person.
            getPersonAndDescendants.Parameter <long>("TotalLevels"); // How many levels will be loaded and the root person is included.
            getPersonAndDescendants.IsComposable = true;

            FunctionConfiguration getPersonAndAncestors = modelBuilder.Function("GetPersonAndAncestors");

            getPersonAndAncestors.ReturnsCollectionFromEntitySet <Person>("People");
            getPersonAndAncestors.Parameter <long>("Id");          // The id of the root person.
            getPersonAndAncestors.Parameter <long>("TotalLevels"); // How many levels will be loaded and the root person is included.
            getPersonAndAncestors.IsComposable = true;

            modelBuilder.Namespace = typeof(Person).Namespace;
            return(modelBuilder.GetEdmModel());
        }
        public static Microsoft.OData.Edm.IEdmModel GetModel()
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <Address>("Address");
            builder.EntitySet <AddressType>("AddressType");
            builder.EntitySet <BusinessEntity>("BusinessEntity");
            builder.EntitySet <BusinessEntityAddress>("BusinessEntityAddress");
            builder.EntitySet <BusinessEntityContact>("BusinessEntityContact");
            builder.EntitySet <ContactType>("ContactType");
            builder.EntitySet <CountryRegion>("CountryRegion");
            builder.EntitySet <EmailAddress>("EmailAddress");
            builder.EntitySet <Password>("Password");
            builder.EntitySet <Person>("Person");
            builder.EntitySet <PersonPhone>("PersonPhone");
            builder.EntitySet <PhoneNumberType>("PhoneNumberType");
            builder.EntitySet <StateProvince>("StateProvince");

            EntitySetConfiguration <Person> persons = builder.EntitySet <Person>("Person");

            FunctionConfiguration myFirstFunction = persons.EntityType.Collection.Function("MyFirstFunction");

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

            return(builder.GetEdmModel());
        }
Exemplo n.º 4
0
        public static IEdmModel GetEdmModel()
        {
            ODataConventionModelBuilder        builder  = new ODataConventionModelBuilder();
            EntityTypeConfiguration <Customer> customer = builder.EntitySet <Customer>("Customers").EntityType;
            EntityTypeConfiguration <Order>    order    = builder.EntitySet <Order>("Orders").EntityType;

            // Add unbound function for get special customer.
            FunctionConfiguration getCustomersWithNameContaining = builder.Function("GetCustomersWithNameContaining");

            getCustomersWithNameContaining.Parameter <string>("ContainedString");
            getCustomersWithNameContaining.ReturnsCollectionFromEntitySet <Customer>("Customers");

            // Add bound action for updating order price.
            ActionConfiguration updateOrderPrice = order.Action("UpdateOrderPrice");

            updateOrderPrice.Parameter <string>("Price");
            updateOrderPrice.ReturnsFromEntitySet <Order>("Orders");

            // Add bound function for delete order from customer and return the rest orders.
            FunctionConfiguration deleteOrderFromCustomer = customer.Function("DeleteOrderFromCustomer");

            deleteOrderFromCustomer.Parameter <int>("OrderId");
            deleteOrderFromCustomer.ReturnsCollectionFromEntitySet <Order>("Orders");

            return(builder.GetEdmModel());
        }
Exemplo n.º 5
0
        private static IEdmModel GetEdmModel()
        {
            ODataConventionModelBuilder builder = new ODataConventionModelBuilder();
            var books = builder.EntitySet <Book>("Books");
            FunctionConfiguration myFirstFunction = books.EntityType.Collection.Function("MyFirstFunction");

            myFirstFunction.ReturnsCollectionFromEntitySet <Book>("Books");
            return(builder.GetEdmModel());
        }
        private IEdmModel GetEdmModel(ODataConventionModelBuilder builder)
        {
            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");

            // Top level function import with complex parameter
            FunctionConfiguration complexFunction = builder.Function("ComplexFunction");

            complexFunction.Parameter <ConventionAddress>("address");
            complexFunction.Returns <string>();

            // Top level function import with entity parameter
            FunctionConfiguration entityFunction = builder.Function("EntityFunction");

            entityFunction.Parameter <ConventionOrder>("order");
            entityFunction.Returns <string>();

            // Top level function import with optional parameter
            FunctionConfiguration optionalFunction = builder.Function("OptionalFunction");

            optionalFunction.Parameter <int>("param").HasDefaultValue("9");
            optionalFunction.Returns <string>();

            return(builder.GetEdmModel());
        }
Exemplo n.º 7
0
        public static IEdmModel GetModel()
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder();

            builder.EntitySet <Address>("Address");
            builder.EntitySet <AddressType>("AddressType");
            builder.EntitySet <BusinessEntity>("BusinessEntity");
            builder.EntitySet <BusinessEntityAddress>("BusinessEntityAddress");
            builder.EntitySet <BusinessEntityContact>("BusinessEntityContact");
            builder.EntitySet <ContactType>("ContactType");
            builder.EntitySet <CountryRegion>("CountryRegion");
            builder.EntitySet <EmailAddress>("EmailAddress");
            builder.EntitySet <Password>("Password");
            builder.EntitySet <Person>("Person");
            builder.EntitySet <PersonPhone>("PersonPhone");
            builder.EntitySet <PhoneNumberType>("PhoneNumberType");
            builder.EntitySet <StateProvince>("StateProvince");

            EntitySetConfiguration <EntityWithEnum> entitesWithEnum
                = builder.EntitySet <EntityWithEnum>("EntityWithEnum");

            FunctionConfiguration functionEntitesWithEnum
                = entitesWithEnum.EntityType.Collection.Function("PersonSearchPerPhoneType");

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

            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");

            builder.ContainerName = "SqliteContext";
            builder.EntitySet <AnimalType>("AnimalType");
            builder.EntitySet <EventData>("EventData");

            builder.EntitySet <Player>("Player");
            builder.EntityType <PlayerStats>();

            SingletonConfiguration <SkillLevels> skillLevels = builder.Singleton <SkillLevels>("SkillLevels");

            builder.EntityType <SkillLevel>();

            return(builder.GetEdmModel());
        }
Exemplo n.º 8
0
        private static void MapWorkflowOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <WorkflowStatusModel>("Workflows")
            .EntityType.HasKey(p => p.Id);
            builder
            .EntitySet <WorkflowActivityModel>("WorkflowActivities")
            .EntityType.HasKey(p => p.IdWorkflowActivity);

            #region [ Functions ]
            FunctionConfiguration myInstances = builder
                                                .EntityType <WorkflowStatusModel>().Collection
                                                .Function("MyInstances");

            myInstances.Namespace = "WorkflowService";
            myInstances.ReturnsCollectionFromEntitySet <WorkflowStatusModel>("Workflows");
            myInstances.Parameter <string>("workflowName");

            FunctionConfiguration myActivities = builder
                                                 .EntityType <WorkflowActivityModel>().Collection
                                                 .Function("MyActivities");
            myActivities.Namespace = "WorkflowService";
            myActivities.ReturnsCollectionFromEntitySet <WorkflowActivityModel>("WorkflowActivities");
            myActivities.Parameter <WorkflowActivityFinderModel>("finder");

            FunctionConfiguration getLastWorkflowActivityFromDocumentUnit = builder
                                                                            .EntityType <WorkflowActivityModel>().Collection
                                                                            .Function("GetLastWorkflowActivityFromDocumentUnit");
            getLastWorkflowActivityFromDocumentUnit.Namespace = "WorkflowService";
            getLastWorkflowActivityFromDocumentUnit.ReturnsFromEntitySet <WorkflowActivityModel>("WorkflowActivities");
            getLastWorkflowActivityFromDocumentUnit.Parameter <Guid>("idDocumentUnit");

            FunctionConfiguration currentWorkflowActivityFromDocumentUnit = builder
                                                                            .EntityType <WorkflowActivityModel>().Collection
                                                                            .Function("CurrentWorkflowActivityFromDocumentUnit");
            currentWorkflowActivityFromDocumentUnit.Namespace = "WorkflowService";
            currentWorkflowActivityFromDocumentUnit.ReturnsFromEntitySet <WorkflowActivityModel>("WorkflowActivities");
            currentWorkflowActivityFromDocumentUnit.Parameter <Guid>("idDocumentUnit");

            FunctionConfiguration getUserAuthorizedWorkflowActivitiesCount = builder
                                                                             .EntityType <WorkflowActivityModel>().Collection
                                                                             .Function("CountUserAuthorizedWorkflowActivities");
            getUserAuthorizedWorkflowActivitiesCount.Namespace = "WorkflowService";
            getUserAuthorizedWorkflowActivitiesCount.Returns <long>();
            getUserAuthorizedWorkflowActivitiesCount.Parameter <WorkflowActivityFinderModel>("finder");

            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
Exemplo n.º 9
0
        private static IEdmModel GetEdmModel(IServiceProvider serviceProvider)
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder(serviceProvider);

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


            builder.EntitySet <vtran>("Vtrans")
            .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<visitorCarType> persons = builder.EntitySet<visitorCarType>("visitorCarType");
            //FunctionConfiguration myFirstFunction = persons.EntityType.Collection.Function("MyFirstFunction");
            //myFirstFunction.ReturnsCollectionFromEntitySet<visitorCarType>("visitorCarType");

            EntitySetConfiguration <vtran> vtran = builder.EntitySet <vtran>("vtran");
            FunctionConfiguration          myFirstFunctiontrans = vtran.EntityType.Collection.Function("MyFirstFunctiontrans");

            myFirstFunctiontrans.ReturnsCollectionFromEntitySet <vtran>("vtran");



            //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());
        }
Exemplo n.º 10
0
        private static void MapCustomModules(ODataModelBuilder builder)
        {
            builder
            .EntitySet <MenuModel>("AUSLRE_BandiDiGaraMenu")
            .EntityType.HasKey(p => p.UniqueId);

            builder
            .EntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives")
            .EntityType.HasKey(p => p.UniqueId);

            #region [ Functions ]
            FunctionConfiguration getMenu = builder
                                            .EntityType <MenuModel>().Collection
                                            .Function("GetMenu");

            getMenu.Namespace = "MenuModelService";
            getMenu.ReturnsCollectionFromEntitySet <MenuModel>("AUSLRE_BandiDiGaraMenu");

            ActionConfiguration countArchiveByGrid = builder
                                                     .EntityType <ArchiveModel>().Collection
                                                     .Action("CountArchiveByGrid");

            countArchiveByGrid.Namespace = "ArchiveModelService";
            countArchiveByGrid.ReturnsCollectionFromEntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives");
            countArchiveByGrid.Parameter <ArchiveFinderModel>("finder");

            ActionConfiguration searchArchiveByGrid = builder
                                                      .EntityType <ArchiveModel>().Collection
                                                      .Action("SearchArchiveByGrid");

            searchArchiveByGrid.Namespace = "ArchiveModelService";
            searchArchiveByGrid.ReturnsCollectionFromEntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives");
            searchArchiveByGrid.Parameter <ArchiveFinderModel>("finder");


            FunctionConfiguration getArchiveInfo = builder
                                                   .EntityType <ArchiveModel>().Collection
                                                   .Function("GetArchiveInfo");

            getArchiveInfo.Namespace = "ArchiveModelService";
            getArchiveInfo.Parameter <Guid>("uniqueId");
            getArchiveInfo.ReturnsCollectionFromEntitySet <ArchiveModel>("AUSLRE_BandiDiGaraArchives");
            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
Exemplo n.º 11
0
        private static void MapDossierOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <DossierModel>("Dossiers")
            .EntityType.HasKey(p => p.UniqueId);
            builder
            .EntitySet <DossierFolderTableValuedModel>("DossierFolders")
            .EntityType.HasKey(p => p.IdDossierFolder);

            #region [ Functions ]

            FunctionConfiguration getDossierById = builder
                                                   .EntityType <DossierModel>().Collection
                                                   .Function("GetDossierById");
            getDossierById.Namespace = "DossierService";
            getDossierById.Parameter <Guid>("id");
            getDossierById.ReturnsCollectionFromEntitySet <DossierModel>("Dossiers");

            FunctionConfiguration getDossierByYearAndNumber = builder
                                                              .EntityType <DossierModel>().Collection
                                                              .Function("GetDossierByYearAndNumber");
            getDossierByYearAndNumber.Namespace = "DossierService";
            getDossierByYearAndNumber.Parameter <short>("year");
            getDossierByYearAndNumber.Parameter <int>("number");
            getDossierByYearAndNumber.ReturnsCollectionFromEntitySet <DossierModel>("Dossiers");

            FunctionConfiguration getNextDossierFolders = builder
                                                          .EntityType <DossierFolderTableValuedModel>().Collection
                                                          .Function("GetNextDossierFolders");
            getNextDossierFolders.Namespace = "DossierService";
            getNextDossierFolders.Parameter <Guid>("id");
            getNextDossierFolders.ReturnsCollectionFromEntitySet <DossierFolderTableValuedModel>("DossierFolders");

            FunctionConfiguration hasChildren = builder
                                                .EntityType <DossierFolderTableValuedModel>().Collection
                                                .Function("HasChildren");
            hasChildren.Namespace = "DossierService";
            hasChildren.Parameter <Guid>("id");
            hasChildren.Returns <bool>();

            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
Exemplo n.º 12
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());
        }
Exemplo n.º 13
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
        }
        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());
        }
Exemplo n.º 15
0
        private static void MapPECMailOData(ODataModelBuilder builder)
        {
            builder
            .EntitySet <PECMailModel>("PECMails")
            .EntityType.HasKey(p => p.Id);


            #region [ Functions ]
            FunctionConfiguration getPECMailsFunc = builder
                                                    .EntityType <PECMailModel>().Collection
                                                    .Function("GetProtocolPECMails");

            getPECMailsFunc.Namespace = "PECMailService";
            getPECMailsFunc.ReturnsCollectionFromEntitySet <PECMailModel>("PECMails");
            getPECMailsFunc.Parameter <short>("year");
            getPECMailsFunc.Parameter <int>("number");
            getPECMailsFunc.Parameter <short>("direction");

            #endregion

            #region [ Navigation Properties ]

            #endregion
        }
Exemplo n.º 16
0
        private IEdmModel GetEdmModel(IServiceProvider service)
        {
            ODataModelBuilder builder = new ODataConventionModelBuilder(service);

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

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

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

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

            //Books
            EntitySetConfiguration <Book> books    = builder.EntitySet <Book>("Books");
            FunctionConfiguration         postBook = books.EntityType.Collection.Function("PostBook");

            postBook.ReturnsCollectionFromEntitySet <Book>("Books");
            FunctionConfiguration deleteBook = books.EntityType.Collection.Function("DeleteBook");

            deleteBook.ReturnsCollectionFromEntitySet <Book>("Books");
            FunctionConfiguration updateBook = books.EntityType.Collection.Function("UpdateBook");

            updateBook.ReturnsCollectionFromEntitySet <Book>("Books");


            //Users
            EntitySetConfiguration <User> users    = builder.EntitySet <User>("Users");
            FunctionConfiguration         register = users.EntityType.Collection.Function("Register");

            register.ReturnsCollectionFromEntitySet <User>("Users");
            FunctionConfiguration authenticate = users.EntityType.Collection.Function("Authenticate");

            authenticate.ReturnsCollectionFromEntitySet <User>("Users");
            FunctionConfiguration deleteUser = users.EntityType.Collection.Function("DeleteUser");

            deleteUser.ReturnsCollectionFromEntitySet <User>("Users");
            FunctionConfiguration updateUser = users.EntityType.Collection.Function("UpdateUser");

            updateUser.ReturnsCollectionFromEntitySet <User>("Users");

            //Categories
            EntitySetConfiguration <Category> categories   = builder.EntitySet <Category>("Categories");
            FunctionConfiguration             postCategory = categories.EntityType.Collection.Function("PostCategory");

            postCategory.ReturnsCollectionFromEntitySet <Category>("Categories");
            FunctionConfiguration deleteCategory = categories.EntityType.Collection.Function("DeleteCategory");

            deleteCategory.ReturnsCollectionFromEntitySet <Category>("Categories");
            FunctionConfiguration updateCategory = categories.EntityType.Collection.Function("UpdateCategory");

            updateCategory.ReturnsCollectionFromEntitySet <Category>("Categories");

            //Categories
            EntitySetConfiguration <YearOld> yearOlds = builder.EntitySet <YearOld>("YearOlds");

            return(builder.GetEdmModel());
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 19
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
        }
Exemplo n.º 20
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
        }
Exemplo n.º 21
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
        }
        // 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());
        }