public void TestInsertOperationWithStringKeySqlServer()
        {
            var carrier = new Carrier();

            using (var tran = new TransactionScope())
            {
                using (var conn = new SqlConnection(ConnectionStringReader.GetSqlServerConnstring()))
                {
                    var createTableScript = conn.GetScriptBuild().GetCreateTableCommand <Carrier>();
                    conn.Execute(createTableScript);

                    conn.Insert <Carrier>(carrier);

                    conn.Execute("Drop table Carrier");
                }

                tran.Complete();
            }
        }
        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);
        }
        public void TestSelectWithSelectExentions()
        {
            var carrier    = new Carrier();
            var createDate = new DateTime(2019, 07, 19);
            var updateDate = new DateTime(2019, 07, 25);

            using (var tran = new TransactionScope())
            {
                using (var conn = new SqlConnection(ConnectionStringReader.GetSqlServerConnstring()))
                {
                    var createTableScript = conn.GetScriptBuild().GetCreateTableCommand <Carrier>();
                    conn.Execute(createTableScript);

                    conn.Insert <Carrier>(carrier);

                    var result = conn.Select <Carrier>(c => c.CreateDate > createDate && c.UpdateDate <= updateDate && c.Name == "Teste");

                    conn.Execute("Drop table Carrier");
                }

                tran.Complete();
            }
        }
        public void TestSelectOperationSqlServer()
        {
            var connection = new SqlConnection(ConnectionStringReader.GetSqlServerConnstring());

            connection.Open();

            using (var scope = new TransactionScope())
            {
                using (var conn = connection)
                {
                    IScriptBuilder builder = new ScriptSqlServerBuilder();

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

                    conn.Execute("drop table [Cliente]");
                }
            }
        }
Beispiel #5
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);
 }