public void TestUpdateMultipleAccess()
        {
            First inst = new First();

            inst.Id   = 56;
            inst.Name = "testMultiple";

            //  Second[] second = inst.GetSecond();

            //insert
            Second ss = new Second();

            ss.Age      = 99;
            ss.Quantity = 890;

            //update
            Second s1 = new Second();

            s1.Id       = 909;
            s1.Quantity = 90;
            s1.Age      = 90;
            s1.FirstId  = 56;



            Second s2 = new Second();

            s2.Id       = 112;
            s2.Quantity = 11;
            s2.Age      = 11;
            s2.FirstId  = 56;

            inst.AttachTableMetadata(s1);
            inst.AttachTableMetadata(s2);

            //delete
            inst.RemoveTableMetadata(s2);

            List <ExecutionQuery> list = SqlGenerator.GenerateMultipleUpdateQueries(DatabaseServer.Access, inst);

            foreach (ExecutionQuery var in list)
            {
                Console.WriteLine(var.Query);
            }


            Assert.IsTrue(list.Count > 0);
        }
        public void TestInsertMultiplePostgreSql()
        {
            Third third = new Third();

            third.ThirdStuff = "lalala";

            Second s = new Second();

            s.Age      = 456;
            s.Quantity = 43;

            s.AttachTableMetadata(third);

            First first = new First();

            first.Name = "Gogu";

            first.AttachTableMetadata(s);

            List <ExecutionQuery> list = SqlGenerator.GenerateMultipleInsertQueries(DatabaseServer.PostgreSql, first);

            foreach (ExecutionQuery var in list)
            {
                Console.WriteLine(var.Query);
            }

            Assert.IsTrue(list.Count > 0);
        }
Exemple #3
0
        public void TestCreateMultiple()
        {
            Third third = new Third();

            third.ThirdStuff = "lalala";

            Second s = new Second();

            s.Age      = 456;
            s.Quantity = 43;

            s.AttachTableMetadata(third);

            First first = new First();

            first.Name = "Gogu";

            first.AttachTableMetadata(s);

            firstPersistent.Create(first);
        }
Exemple #4
0
        public void ExecuteMultipleOperationsInTransaction()
        {
            Session s = Session.CreateNewSession(DatabaseServer.SqlServer, SharedData.sqlserver);

            CategoryTableMetadata    ctm        = new CategoryTableMetadata();
            CategoryPersistentObject persistent = new CategoryPersistentObject(s, ctm);

            First first = new First();
            FirstPersistentObject fp = new FirstPersistentObject(s, first);

            Third third = new Third();

            third.ThirdStuff = "lalala";

            Second sp = new Second();

            sp.Age      = 456;
            sp.Quantity = 43;

            sp.AttachTableMetadata(third);


            first.Name = "Crocodilu";

            first.AttachTableMetadata(sp);



            s.BeginTransaction();

            QueryCriteria qc = new QueryCriteria(ctm.TableName, ctm.TableFields[0]);

            qc.Add(CriteriaOperator.Max, ctm.TableFields[0]);

            //get the last one
            CategoryTableMetadata[] ct = (CategoryTableMetadata[])persistent.GetTableMetadata(qc);
            persistent.Delete(ct[0]);



            CategoryTableMetadata cc = new CategoryTableMetadata();

            cc.CategoryName = "fluffy";
            cc.Description  = "tingling";

            persistent.Create(cc);

            fp.Create(first);


            List <ExecutionQuery> scc = s.Queries;


            for (int i = 0; i < scc.Count; i++)
            {
                Console.WriteLine(scc[i]);
            }


            s.Commit();
        }