Ejemplo n.º 1
0
        public void TestSelectSqlServerByFieldsParametersAndTableMetadata()
        {
            CategoryPersistentObject cpo   = new CategoryPersistentObject(DatabaseServer.SqlServer, SharedData.sqlserver, this.ctg);
            ExecutionQuery           query = SqlGenerator.GenerateSelectQuery(DatabaseServer.SqlServer, ctg, ctg.TableFields[1]);

            Console.WriteLine(query);
            Assert.IsTrue(query.Query != string.Empty);
        }
Ejemplo n.º 2
0
        public void TestSelectSqlServerByAllFields()
        {
            CategoryPersistentObject cpo   = new CategoryPersistentObject(DatabaseServer.SqlServer, SharedData.sqlserver, this.ctg);
            ExecutionQuery           query = SqlGenerator.GenerateSelectQuery(DatabaseServer.SqlServer, ctg, false);

            Console.WriteLine(query);
            Assert.IsTrue(query.Query != string.Empty);
        }
Ejemplo n.º 3
0
        public void TestSelectPostgreByPrimaryKey()
        {
            CategoryPersistentObject cpo   = new CategoryPersistentObject(DatabaseServer.PostgreSql, SharedData.sqlserver, this.ctg);
            ExecutionQuery           query = SqlGenerator.GenerateSelectQuery(DatabaseServer.PostgreSql, ctg, true);

            Console.WriteLine(query);
            Assert.IsTrue(query.Query != string.Empty);
        }
Ejemplo n.º 4
0
        public void TestSelectPostgreWithTableName()
        {
            CategoryPersistentObject cpo   = new CategoryPersistentObject(DatabaseServer.PostgreSql, SharedData.sqlserver, this.ctg);
            ExecutionQuery           query = SqlGenerator.GenerateSelectQuery(DatabaseServer.PostgreSql, ctg.TableName, ctg.TableFields[0], ctg.TableFields[1]);

            Console.WriteLine(query);
            Assert.IsTrue(query.Query != string.Empty);
        }
        public void Init()
        {
            Configuration.ReadConfigurationFromConfigFile();

            ctm = new CategoryTableMetadata();
            cpo = new CategoryPersistentObject(DatabaseServer.Access, SharedData.access, ctm);

            firstTable      = new First();
            firstPersistent = new FirstPersistentObject(DatabaseServer.Access, SharedData.access, firstTable);
        }
Ejemplo n.º 6
0
        public void TestMultipleReadExecuteOperations()
        {
            Session s = Session.CreateNewSession(DatabaseServer.SqlServer, SharedData.sqlserver);
            CategoryTableMetadata    ctm = new CategoryTableMetadata();
            CategoryPersistentObject cpo = new CategoryPersistentObject(s, ctm);
            DataSet ds = cpo.GetDataSet();

            s.Close();
            Assert.IsTrue(ds.Tables[0].Rows.Count > 0);
        }
Ejemplo n.º 7
0
        public void TestSelectSqlServerByDatabaseFieldsAndPrimaryKeyCondition()
        {
            CategoryPersistentObject cpo = new CategoryPersistentObject(DatabaseServer.SqlServer, SharedData.sqlserver, this.ctg);

            DatabaseField[] ff    = new DatabaseField[] { this.ctg.TableFields[0] };
            ExecutionQuery  query = SqlGenerator.GenerateSelectQuery(DatabaseServer.SqlServer, ctg.TableName, ff, true);

            Console.WriteLine(query);
            Assert.IsTrue(query.Query != string.Empty);
        }
Ejemplo n.º 8
0
        public void TestSelectAccessWithQuerySelect()
        {
            CategoryPersistentObject cpo   = new CategoryPersistentObject(DatabaseServer.Access, SharedData.sqlserver, this.ctg);
            QueryCriteria            qc    = new QueryCriteria(this.ctg);
            ExecutionQuery           query = SqlGenerator.GenerateSelectQuery(DatabaseServer.Access, ctg);

            Console.WriteLine(query);

            Assert.IsTrue(query.Query != string.Empty);
        }
Ejemplo n.º 9
0
        public void TestConvertToHashtable()
        {
            CategoryTableMetadata    c   = new CategoryTableMetadata();
            CategoryPersistentObject cto = new CategoryPersistentObject(DatabaseServer.SqlServer, SharedData.sqlserver, c);

            CategoryTableMetadata[] categs = (CategoryTableMetadata[])cto.GetTableMetadata();

            Hashtable dt = DataConvertor.ConvertToHashtable(categs, categs[0].GetField(0), categs[0].GetField(1));

            Assert.IsTrue(dt.Count > 0);
        }
Ejemplo n.º 10
0
        public void TestConvertToDataTableOverload2()
        {
            CategoryTableMetadata    c   = new CategoryTableMetadata();
            CategoryPersistentObject cto = new CategoryPersistentObject(DatabaseServer.SqlServer, SharedData.sqlserver, c);

            CategoryTableMetadata[] categs = (CategoryTableMetadata[])cto.GetTableMetadata();

            DataTable dt = DataConvertor.ConvertToDataTable(categs, categs[0].GetField(1), categs[0].GetField(2));

            Assert.IsTrue(categs.Length > 0);
        }
Ejemplo n.º 11
0
        public void TestSelectAccessByDatabaseFieldsAndWithCondtitionalDatabaseDields()
        {
            CategoryPersistentObject cpo = new CategoryPersistentObject(DatabaseServer.Access, SharedData.sqlserver, this.ctg);

            DatabaseField[] ff    = new DatabaseField[] { this.ctg.TableFields[0] };
            ExecutionQuery  query = SqlGenerator.GenerateSelectQuery(DatabaseServer.Access, ctg.TableName, ff, ctg.TableFields[1]);


            Console.WriteLine(query);
            Assert.IsTrue(query.Query != string.Empty);
        }
Ejemplo n.º 12
0
        public void Init()
        {
            Configuration.ReadConfigurationFromConfigFile();

            ctm = new CategoryTableMetadata();
            cpo = new CategoryPersistentObject(DatabaseServer.Oracle, SharedData.sqlserver, ctm);

            firstTable      = new First();
            firstPersistent = new FirstPersistentObject(DatabaseServer.Oracle, SharedData.sqlserver, firstTable);

            //prepare the database
        }
Ejemplo n.º 13
0
        private void Form1_Load(object sender, EventArgs e)
        {
            Configuration.ReadConfigurationFromConfigFile();

            CategoryTableMetadata    c   = new CategoryTableMetadata();
            CategoryPersistentObject cpo = new CategoryPersistentObject(c);

            CategoryTableMetadata[] fg = (CategoryTableMetadata[])cpo.GetTableMetadata();



            dataGridView1.DataSource = fg;
        }
Ejemplo n.º 14
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();
        }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            CategoryTableMetadata    ctm = new CategoryTableMetadata();
            CategoryPersistentObject cpo = new CategoryPersistentObject(EDatabase.SqlServer, sqlserver, ctm);

            cpo.BeforeExecutingQueries += new PersistentObject.SqlGeneratorEventHandler(cpo_BeforeExecutingQueries);

            ctm.CategoryName = "Zmeura";
            ctm.Description  = "Zmeura d-aia buna";

            bool b = ctm.IsNull(0);

            cpo.Create(ctm);


            bool bn = ctm.IsNull(0);


            int s = ctm.CategoryID;


//
//            OrderDetailsTableMetadata orderDetails = new OrderDetailsTableMetadata();
//            OrdersTableMetadata order = new OrdersTableMetadata();

//            CustomerTableMetadata c = new CustomerTableMetadata();
//            QueryCriteria qc = new QueryCriteria(c);
//            qc.Add(CriteriaOperator.Distinct, c.TableFields[0]);
//            IQueryCriteriaGenerator ss = DataFactory.InitializeQueryCriteriaGenerator(EDatabase.SqlServer);
//            string s = ss.Generate(qc);
//
//
//
//
//             FirstTableMetadata first = new FirstTableMetadata();
//             SecondTableMetadata second = new SecondTableMetadata();
//             ThirdTableMetadata third = new ThirdTableMetadata();
//
//             FirstPersistentObject psqlserver= new FirstPersistentObject(EDatabase.SqlServer,Program.sqlserver, first);
//             FirstPersistentObject msqlserver = new FirstPersistentObject(EDatabase.MySQL, "FGHFH", first);
//             FirstPersistentObject asqlserver = new FirstPersistentObject(EDatabase.Access, "dfdg", first);
//
//
//             QueryCriteria qcFirst = new QueryCriteria(first);
//             QueryCriteria qcSecond = new QueryCriteria(second);
//             QueryCriteria qcThird = new QueryCriteria(third);
//
//             qcThird.Add(CriteriaOperator.Equality, third.TableFields[1], "tt");
//
//
//             qcFirst.AddJoin(JoinType.Inner, first.TableFields[0], second.TableFields[1], qcSecond);
//             qcFirst.AddJoin(JoinType.Left, second.TableFields[0], third.TableFields[2], qcThird);
//
//
//
//            DataSet ds = psqlserver.GetDataSet(qcFirst);



//            QueryCriteria qc = new QueryCriteria(order);
//            qc.Add(CriteriaOperator.Equality, qc.Fields[0], 10257);
//
//            QueryCriteria qcOrderDetails = new QueryCriteria(orderDetails);
//            qcOrderDetails.Add(CriteriaOperator.Equality, orderDetails.GetField("Discount"), 0);
//
//            qc.AddJoin(JoinType.Inner, order.TableFields[0], orderDetails.TableFields[0], qcOrderDetails);
//
//
//
//            DataSet ds = cpo.GetDataSet(qc);



            // Console.WriteLine("X");



            // TestSqlServerOr();

//			FileStream fs = null;
//
//			try
//			{
//				fs = new FileStream(@"d:\snap.jpg", FileMode.Open, FileAccess.Read);
//				byte[] b = new byte[fs.Length];
//				fs.Read(b, 0, b.Length);
//				CategoriesTableMetadata ab = new CategoriesTableMetadata();
//				//ab.CategoryID = 1;
//				ab.CategoryName = "Seafood";
//				ab.Description = "MARius";
//				ab.Picture = b;
//				string s = SqlGenerator.GenerateInsertQuery(EDatabase.SqlServer, ab.TableFields, ab.TableName);
//				DataAccessLayer.ExecuteNonQuery(EDatabase.SqlServer, Program.sqlserver, s);
//
//			}
//			finally
//			{
//				if (fs != null)
//				{
//					fs.Close();
//				}
//			}


//            CategoriesTableMetadata aom = new CategoriesTableMetadata();
//
//            QueryCriteria q = new QueryCriteria(aom.TableName, aom.TableFields[0], aom.TableFields[2]);
//            q.Add(CriteriaOperator.OrderBy, aom.TableFields[0], "asc");
//
//            DataSet dsmh = ctg.GetDataSet(q);
//
//            CategoriesTableMetadata[] c = (CategoriesTableMetadata[]) ctg.GetTableMetadata(q);
//



//			ExtenderTerritories.TerritoriesTableMetadata etp = new ExtenderTerritories.TerritoriesTableMetadata();
////			ExtenderTerritories.TerritoriesPersistentObject top = new ExtenderTerritories.TerritoriesPersistentObject(EDatabase.SqlServer, sqlserver, etp);
////
////			CategoriesTableMetadata[] tp = ctg.MapDataReaderToTableMetadata();
////
////			Program.b = tp[0].Picture;
//
//
//			CategoriesTableMetadata[] ct = (CategoriesTableMetadata[])ctg.GetTableMetadata();
//
//            DataSet ds = ctg.GetDataSet();

            //Form1 f = new Form1();
            //System.Windows.Forms.Application.Run(f);


//
//
//
//			try
//			{
//
//
//
//				CategoriesTableMetadata[] categ = ctg.MapDataReaderToTableMetadata();
//
//				foreach (CategoriesTableMetadata c in categ)
//				{
//					System.Console.WriteLine(c.Description);
//				}
//
//			}
//			catch (Exception ex)
//			{
//				System.Console.WriteLine(ex.Message);
//			}

//			DataSet ds = ctg.GetDataSet();
//
//
//			CategoriesTableMetadata cn = (CategoriesTableMetadata)ctg.MapDataReaderToTableMetadata(3);
//
//



//            AbonatTableMetadata aom = new AbonatTableMetadata();
//            AbonatCrapTableMetadata aa = new AbonatCrapTableMetadata();
//            AbonatPersistentObject aop = new AbonatPersistentObject(EDatabase.SqlServer, Program.sqlserver, aom);
//
//           // AbonatTableMetadata abonat = (AbonatTableMetadata)aop.MapDataReaderToTableMetadata(26);
//
//
//            aom.CartiImprumutate = 345;
//            aom.CodAbonament = "3242345";
//            aom.DataNasterii = DateTime.Now;
//            aom.Nume = "al_doileeeeeeeeeeeeeeeea";
//            aom.Nota = "dark";
//            aom.Prenume = "spider";
//
//
//			//test sql generator
//
//			string s = SqlGenerator.GenerateSelectQuery(EDatabase.SqlServer, aom.TableName);
//			System.Console.WriteLine(s);
//
//			string ss = SqlGenerator.GenerateSelectQuery(EDatabase.SqlServer, aom.TableName, aom.TableFields[1], aom.TableFields[2]);
//			System.Console.WriteLine(ss);
//
//			string sss = SqlGenerator.GenerateSelectQuery(EDatabase.SqlServer, aom, true);
//			System.Console.WriteLine(sss);
////
//			string m = SqlGenerator.GenerateSelectQuery(EDatabase.SqlServer, aom, false);
//			System.Console.WriteLine(m);


//
//			string ns = SqlGenerator.GenerateDeleteQuery(EDatabase.Access, aom, true);
//
//			//test insert sql generator
//
//
//			System.Console.WriteLine("end");
//


//
//            try
//            {
//
//                aop.BeginTransaction();
//
//                aop.Create(aom, aa);
//                aop.Delete(abonat);
//
//                aop.Commit();
//
//            }
//            catch (Exception ex)
//            {
//                aop.Rollback();
//            }


            //
//            aom = (AbonatTableMetadata) aop.MapDataReaderToTableMetadata(8);
//
//            aop.Delete(aom,true);

//
//            aom.CartiImprumutate = 4353;
//            aom.CodAbonament = "2342342";
//            aom.DataNasterii = DateTime.Now;
//            aom.Nota = "pussy";
//            aom.Nume = "gogu";
//            aom.Prenume = "kkko cu lapter";
//
//
//
//            aa.Blah = "spanac";
//
//            aop.Create(aom, aa);



//            aom.CartiImprumutate = 3453;
//            aom.CodAbonament = "345435345";
//            aom.DataNasterii = DateTime.Now;
//            aom.Nota = "blaj";
//            aom.Nume = "blahhhhhhhhhhhhhhh";
//            aom.Prenume = "sticks";
//
//
//
//            aop.Create(aom);


            // DataSet ds = aop.GetRelationData("FK_AbonatAbonatCrap", 12);
        }