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\"");
        }
Example #2
0
        public void SapHanaSelectContractWhereName()
        {
            var conn = new Sap.Data.Hana.HanaConnection();

            conn.ConnectionString = ConnectionStringReader.GetConnstring("hana");

            var dicTypes = new Dictionary <int, string>();

            dicTypes.Add(1, "Teste");
            var currentDate = new DateTime(2019, 1, 1);
            var contractId  = 2;

            foreach (var item in dicTypes)
            {
                conn.Select <ProductSaleReport>(c => c.SaleDate == currentDate && c.RevenueTypeId == item.Key && c.ContractId == contractId).LastOrDefault();
            }


            //var conn = new Sap.Data.Hana.HanaConnection();
            //conn.ConnectionString = ConnectionStringReader.GetConnstring("hana");
            //var scriptBuilder = conn.GetScriptBuild();

            //var contract = TestData.GetContract();

            //var createTableScript = scriptBuilder.GetCreateTableCommand<Contract>();
            //conn.Execute(createTableScript);
            //var id = conn.InsertReturningId<Contract>(contract);

            //var contracts = conn.Select<Contract>(c => c.BusinessPartnerName == "MOISÉS J. MIRANDA" && c.ID==1 && c.TypeContract==0);

            //Assert.AreEqual(1, contracts.Count());
            //Assert.AreEqual("MOISÉS J. MIRANDA", contracts.ToList()[0].BusinessPartnerName);
            //conn.Execute("drop table \"Contract\"");
        }
        public void TestHanaCreateTableScriptShorts()
        {
            IScriptBuilder builder = new ScriptHanaBuilder();

            var connStr = ConnectionStringReader.GetConnstring("hana");
            var conn    = new HanaConnection(connStr);
            var sql     = $@"SELECT 
	                [OUSR].[USER_CODE], 
	                [OUSR].[USERID], 
	                [OUSR].[U_NAME], 
	                [dpto].[Name] as [DepartmentName],
	                [OUSR].[Department],
	                [OUSR].[GENDER],
	                [OUSR].[objType],
	                [OUSR].[userSign],
	                [OUSR].[SUPERUSER],
	                [OUSR].[updateDate]
                    FROM 
	                [OUSR] left join 
	                [OUDP] [dpto] on  [dpto].[Code] = [OUSR].[Department]"    .Replace("[", "\"").Replace("]", "\"");
            var users   = conn.Query <OUSR>(sql);
        }
Example #4
0
 public void SapHanaDeleteModel222()
 {
     var conn   = new Sap.Data.Hana.HanaConnection(ConnectionStringReader.GetConnstring("hana"));
     var sql    = "SELECT * FROM \"@IV_LP_LABELMODEL\"";
     var result = conn.Query <LabelModel>(sql);
 }