Ejemplo n.º 1
0
        public void TestInsertOperationHana()
        {
            var hanaConnection = System.Data.Common.DbProviderFactories.GetFactory("Sap.Data.Hana").CreateConnection();

            hanaConnection.ConnectionString = ConfigurationManager.ConnectionStrings["hana"].ConnectionString;
            hanaConnection.Open();
            var trans = hanaConnection.BeginTransaction();

            using (var conn = hanaConnection)
            {
                IScriptBuilder builder = new ScriptHanaBuilder();

                var cliente = new Cliente()
                {
                    Id = 1, Nome = "Moisés", Ativo = true
                };

                var createTableScript = builder.GetCreateTableCommand <Cliente>();
                builder.Execute(createTableScript, conn);

                var lastId = conn.InsertReturningId <Cliente>(cliente);
                Assert.AreEqual(1, lastId);

                trans.Rollback();
                builder.Execute("drop table \"Cliente\"", hanaConnection);
            }
        }
Ejemplo n.º 2
0
        public void TestInsertOperationWithAttributeTableHana()
        {
            var hanaConnection = System.Data.Common.DbProviderFactories.GetFactory("Sap.Data.Hana").CreateConnection();

            hanaConnection.ConnectionString = ConfigurationManager.ConnectionStrings["hana"].ConnectionString;
            hanaConnection.Open();
            var trans = hanaConnection.BeginTransaction();

            using (var conn = hanaConnection)
            {
                IScriptBuilder builder = new ScriptHanaBuilder();

                var user = new UserSystem()
                {
                    Name = "Moisés", Email = "*****@*****.**", LoginName = "mosheh"
                };

                var createTableScript = builder.GetCreateTableCommand <UserSystem>();
                builder.Execute(createTableScript, conn);

                var lastId = conn.InsertReturningId <UserSystem>(user);
                Assert.AreEqual(1, lastId);

                trans.Rollback();
                builder.Execute("drop table \"IV_MD_SystemUser\"", hanaConnection);
            }
        }
Ejemplo n.º 3
0
        public void TestInsertOperationHanaShortTypes()
        {
            IScriptBuilder builder = new ScriptHanaBuilder();

            var cliente = new Employee()
            {
                Id = 1, Name = "Moisés", Age = 25
            };
            var hanaConnection = new HanaConnection();

            hanaConnection.ConnectionString = ConnectionStringReader.GetConnstring("hana");
            hanaConnection.Open();
            var trans = hanaConnection.BeginTransaction();

            var createTableScript = builder.GetCreateTableCommand <Employee>();

            hanaConnection.Execute(createTableScript);

            hanaConnection.Insert <Employee>(cliente);

            var employeeFromDatabase = hanaConnection.GetAll <Employee>();

            Assert.AreEqual(1, employeeFromDatabase.Count());

            hanaConnection.Execute("drop table \"Employee\"");
        }
Ejemplo n.º 4
0
        public void TestHanaCreateContractTableScript()
        {
            IScriptBuilder builder = new ScriptHanaBuilder();

            var contract = new Contract()
            {
                ID = 1, BusinessPartner = "123", DocTotal = 10000, SignatureDate = DateTime.Now, ContractDate = DateTime.Now
            };

            var createTableScript = builder.GetCreateTableCommand <Contract>();
            var resultadoEsperado = "create table \"Contract\" (\"ID\" INTEGER not null primary key generated by default as IDENTITY, \"Status\" INTEGER, \"ContractDate\" Date, \"Proposal\" INTEGER, \"BusinessPartner\" VARCHAR(255), \"BusinessPartnerName\" VARCHAR(255), \"TypeContract\" INTEGER, \"Undertaking\" INTEGER, \"UndertakingName\" VARCHAR(255), \"UndertakingBlock\" VARCHAR(255), \"UndertakingUnit\" INTEGER, \"UndertakingUnitName\" VARCHAR(255), \"Property\" DECIMAL(18,6), \"PropertyRate\" DECIMAL(18,6), \"Classification\" INTEGER, \"ClassificationDate\" Date, \"RenegotiationRate\" DECIMAL(18,6), \"AnticipationRate\" DECIMAL(18,6), \"AnticipationRateTP\" DECIMAL(18,6), \"TypeFineResidue\" INTEGER, \"FineRateResidue\" DECIMAL(18,6), \"DeliveryDate\" Date, \"SignatureDate\" Date, \"CostCenter\" VARCHAR(255), \"ContractOrigin\" INTEGER, \"ProRataLow\" BOOLEAN, \"ProRataDiscount\" BOOLEAN, \"ProRataLowDelay\" BOOLEAN, \"ProRataResidue\" BOOLEAN, \"ProRataAnticipation\" BOOLEAN, \"DirectComission\" DECIMAL(18,6), \"TotalComission\" DECIMAL(18,6), \"GenerateCreeditLetterOnOverPayment\" BOOLEAN, \"StatusDate\" Date, \"Comments\" VARCHAR(255), \"TypeCalcMora\" INTEGER, \"DocTotal\" DECIMAL(18,6), \"SaleValue\" DECIMAL(18,6), \"AssignmentRights\" BOOLEAN, \"AdjustmentOnlyCalculateDueDate\" BOOLEAN, \"NotGenerateNegativeMonetaryCorrection\" BOOLEAN, \"LagOfInterestDay\" INTEGER, \"LagOfFine\" INTEGER, \"AccPeriodId\" INTEGER, \"MonthsOfGrowthForCorrectionYearly\" INTEGER, \"AccountNumber\" INTEGER, \"Accounted\" BOOLEAN, \"InstructionBoE\" VARCHAR(255), \"BlockPaymentWithFutureDate\" BOOLEAN, \"CostUnit\" DECIMAL(18,6), \"EnableDiscountPunctuality\" BOOLEAN, \"NumberInstallmentsPunctuality\" INTEGER, \"RealEstateTransferDays\" INTEGER, \"AdministrationRate\" DECIMAL(18,6), \"RentalTransferGuaranteed\" BOOLEAN)";

            Assert.AreEqual(resultadoEsperado, createTableScript);
        }
Ejemplo n.º 5
0
        public void TestHanaCreateTableScript()
        {
            IScriptBuilder builder = new ScriptHanaBuilder();

            var cliente = new Cliente()
            {
                Id = 1, Nome = "Moisés", Ativo = true
            };

            var createTableScript = builder.GetCreateTableCommand <Cliente>();
            var resultadoEsperado = "create table \"Cliente\" (\"Id\" INTEGER not null primary key generated by default as IDENTITY, \"Nome\" VARCHAR(255), \"Ativo\" BOOLEAN, \"TotalPedidos\" INTEGER, \"ValorTotalNotasFiscais\" DOUBLE, \"Credito\" DECIMAL(18,6), \"UltimoValorDeCompra\" DECIMAL(18,6))";

            Assert.AreEqual(resultadoEsperado, createTableScript);
        }
Ejemplo n.º 6
0
        public void TestHanaCreateTableScriptShortTypes()
        {
            IScriptBuilder builder = new ScriptHanaBuilder();

            var cliente = new Employee()
            {
                Id = 1, Name = "Moisés", Age = 25
            };

            var createTableScript = builder.GetCreateTableCommand <Employee>();
            var resultadoEsperado = "create column table \"Employee\" (\"Id\" SMALLINT primary key generated by default as IDENTITY, \"Age\" SMALLINT, \"Name\" VARCHAR(255))";

            Assert.AreEqual(resultadoEsperado, createTableScript);
        }
Ejemplo n.º 7
0
        public void TestSelectOperationHana()
        {
            var hanaConnection = System.Data.Common.DbProviderFactories.GetFactory("Sap.Data.Hana").CreateConnection();

            hanaConnection.ConnectionString = ConfigurationManager.ConnectionStrings["hana"].ConnectionString;
            hanaConnection.Open();
            var trans = hanaConnection.BeginTransaction();

            using (var conn = hanaConnection)
            {
                IScriptBuilder builder = new ScriptHanaBuilder();

                var cliente = new Cliente()
                {
                    Id = 1, Nome = "Moisés", Ativo = true
                };
                var cliente2 = new Cliente()
                {
                    Id = 2, Nome = "José", Ativo = true
                };

                var createTableScript = builder.GetCreateTableCommand <Cliente>();
                var insertScript1     = builder.GetInsertCommand <Cliente>(cliente);
                var insertScript2     = builder.GetInsertCommand <Cliente>(cliente2);
                builder.Execute(createTableScript, conn);
                builder.Execute(insertScript1, conn);
                builder.Execute(insertScript2, conn);

                var clientes = conn.GetAll <Cliente>();
                Assert.AreEqual(2, clientes.Count());
                Assert.AreEqual("Moisés", clientes.ToList()[0].Nome);
                Assert.AreEqual("José", clientes.ToList()[1].Nome);

                trans.Rollback();
                builder.Execute("drop table \"Cliente\"", hanaConnection);
            }
        }