Exemplo n.º 1
0
		public static void Main (string[] args)
		{
		
			OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();
			using (IDbConnection db =
				       "User=SYSDBA;Password=masterkey;Database=employee.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
			using ( IDbCommand dbConn = db.CreateCommand())
			{
				Schema fbd= new Schema(){
					Connection = db
				};

				ClassWriter cw = new ClassWriter(){
					Schema=fbd,
					GenerateMetadata=true,
					//SpaceName= "your.app.namespace",
					//OutputDirectory="outputpath"
					//Usings="Using System;\nUsing System.Data\n"
				};

				foreach(var t in fbd.Tables){
					Console.Write("Generating POCO Class for table:'{0}'...", t.Name);
					cw.WriteClass( t);	
					Console.WriteLine(" Done.");
				}
				Console.WriteLine("---------------------------------");
				Console.WriteLine("See classes in: '{0}'", cw.OutputDirectory);
			

			}


			Console.WriteLine ("This is The End my friend!");
			
		}
Exemplo n.º 2
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Config.DialectProvider = new FirebirdDialectProvider();
            using (IDbConnection db =
                       ("User=SYSDBA;Password=masterkey;Database=GYM.FDB;" +
                        "DataSource=localhost;Dialect=3;charset=ISO8859_1;").OpenDbConnection())
                using (IDbCommand dbConn = db.CreateCommand())
                {
                    Schema fbd = new Schema()
                    {
                        Connection = db
                    };

                    ClassWriter cw = new ClassWriter()
                    {
                        Schema    = fbd,
                        SpaceName = "SuperGym.Records",
                        Usings    = "using System;\n" +
                                    "using System.ComponentModel.DataAnnotations;\n" +
                                    "using ServiceStack.Common;\n" +
                                    "using ServiceStack.DataAnnotations;\n" +
                                    "using ServiceStack.OrmSimple;\n"
                    };

                    //var tables = fbd.Tables;
                    //foreach(var t in tables){
                    //	cw.WriteClass(t);
                    //}


                    Table t = new Table()
                    {
                        Name = "SALDOPORCOBRAR"
                    };
                    cw.WriteClass(t);
                }

            Console.WriteLine("This is The End my friend!");
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Hello World!");

            Config.DialectProvider = new FirebirdDialectProvider();
            using (IDbConnection db =
                   ("User=SYSDBA;Password=masterkey;Database=GYM.FDB;" +
                   	"DataSource=localhost;Dialect=3;charset=ISO8859_1;").OpenDbConnection())
            using ( IDbCommand dbConn = db.CreateCommand())
            {

                Schema fbd= new Schema(){
                    Connection = db
                };

                ClassWriter cw = new ClassWriter(){
                    Schema=fbd,
                    SpaceName="SuperGym.Records",
                    Usings= "using System;\n"+
                    "using System.ComponentModel.DataAnnotations;\n"+
                    "using ServiceStack.Common;\n"+
                    "using ServiceStack.DataAnnotations;\n"+
                    "using ServiceStack.OrmSimple;\n"

                };

                //var tables = fbd.Tables;
                //foreach(var t in tables){
                //	cw.WriteClass(t);
                //}

                Table t = new Table(){Name=	"SALDOPORCOBRAR"};
                cw.WriteClass(t);

            }

            Console.WriteLine ("This is The End my friend!");
        }
Exemplo n.º 4
0
        /// <summary>Main entry-point for this application.</summary>
        /// <param name="args">Array of command-line argument strings.</param>
		public static void Main (string[] args)
		{
		
			OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();
			using (IDbConnection db =
				       "User=SYSDBA;Password=masterkey;Database=employee.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
			using ( IDbCommand dbConn = db.CreateCommand())
			{
				Schema fbd= new Schema(){
					Connection = db
				};

				ClassWriter cw = new ClassWriter(){
					Schema=fbd,
					GenerateMetadata=true,
					//SpaceName= "your.app.namespace",
					//OutputDirectory="outputpath"
					//Usings="Using System;\nUsing System.Data\n"
				};

				foreach(var t in fbd.Tables){
					Console.Write("Generating POCO Class for table:'{0}'...", t.Name);
					cw.WriteClass( t);	
					Console.WriteLine(" Done.");
				}
				Console.WriteLine("---------------------------------");
				Console.WriteLine("See classes in: '{0}'", cw.OutputDirectory);
				
				//compilar ...
				CompilerParameters cp = new CompilerParameters();
				cp.GenerateExecutable=false;
				cp.GenerateInMemory=false;
				cp.ReferencedAssemblies.AddRange(
					new string[]{
						"System.dll",
						"System.ComponentModel.DataAnnotations.dll",
						Path.Combine( Directory.GetCurrentDirectory(), "NServiceKit.OrmLite.dll"),
						Path.Combine( Directory.GetCurrentDirectory(), "NServiceKit.Common.dll"),
						Path.Combine( Directory.GetCurrentDirectory(),"NServiceKit.Interfaces.dll")
				});
				cp.OutputAssembly= Path.Combine(cw.OutputDirectory, cw.SpaceName+".dll");
				
				var providerOptions = new Dictionary<string,string>();
    			providerOptions.Add("CompilerVersion", "v3.5");
				
				CodeDomProvider cdp =new CSharpCodeProvider(providerOptions);
			
				string [] files = Directory.GetFiles(cw.OutputDirectory,"*.cs");
				CompilerResults cr= cdp.CompileAssemblyFromFile(cp, files);
				
				if( cr.Errors.Count==0){
					Console.WriteLine("Generated file {0}", Path.Combine(cw.OutputDirectory, cw.SpaceName+".dll")); 
				}
            	else{							
            		foreach (CompilerError ce in cr.Errors)
                		Console.WriteLine(ce.ErrorText);
				}
				
						
			

			}


			Console.WriteLine ("This is The End my friend!");
			
		}
Exemplo n.º 5
0
		public static void Main (string[] args)
		{
			OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();
			
			
			using (IDbConnection db =
			       "User=SYSDBA;Password=masterkey;Database=employee.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
			{
			
				Schema fbd= new Schema(){
					Connection = db
				};
		
				Console.WriteLine("--------TABLES-------------");
				
				var tables = fbd.Tables;
				
				foreach(Table t in tables){
					Console.WriteLine(t.Name);
				}
								
				Console.WriteLine("-------users's owner--------------");
				
				
				Table t1 = fbd.GetTable("USERS");
				Console.WriteLine(t1.Owner);
				
				Console.WriteLine ("---------user's columns ----------------");
				
				var Columns = fbd.GetColumns("USERS");
					
				foreach(Column cl in Columns){
					Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} ",
					                  cl.Name,cl.Position, cl.Nullable, cl.Length, cl.DbType, cl.NetType, cl.Sequence);	
				}
				
				Console.WriteLine("--------------------------------------------");
				
				Console.WriteLine("EMPLOYEE's Columns ");
				
				Columns = fbd.GetColumns("EMPLOYEE");
				
				foreach(Column cl in Columns){
					Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} -- Computed {7} ",
					                  cl.Name,cl.Position, cl.Nullable, cl.Length, cl.DbType,
					                  cl.NetType, cl.Sequence,cl.IsComputed);	
				}
				
				Columns = fbd.GetColumns("COMPANY");
				
				foreach(Column cl in Columns){
					Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} ",
					                  cl.Name,cl.Position, cl.Nullable, cl.Length, cl.DbType, cl.NetType, cl.Sequence);	
				}
				
				Console.WriteLine("--------------------------------------------");
				
				Console.WriteLine("-----------------Procedure---------------------------");
				
				Console.WriteLine ("----- ADD_EMP_PROJ ----");
				
				Procedure p = fbd.GetProcedure("ADD_EMP_PROJ");
				Console.WriteLine("p.Name {0} p.Owner {1} p.Inputs {2} p.Outputs {3} p.Type {4}",
				                  p.Name, p.Owner, p.Inputs, p.Outputs, p.Type);
				
				var parameters = fbd.GetParameters(p);
				foreach( var par in parameters){
					Console.WriteLine("p.ProcedureName {0} p.Name {1} p.Position {2} p.ParameterType {3} p.DbType {4} p.NetType {5}",
					                  par.ProcedureName, par.Name, par.Position, par.Direction, par.DbType, par.NetType);
				}
				
				
				Console.WriteLine ("----- ALL_LANGS ----");
				p = fbd.GetProcedure("ALL_LANGS");
				Console.WriteLine("p.Name {0} p.Owner {1} p.Inputs {2} p.Outputs {3} p.Type {4}",
				                  p.Name, p.Owner, p.Inputs, p.Outputs, p.Type);
				
				
				parameters = fbd.GetParameters(p);
				
				parameters = fbd.GetParameters(p);
				foreach( var par in parameters){
					Console.WriteLine("p.ProcedureName {0} p.Name {1} p.Position {2} p.ParameterType {3} p.DbType {4} p.NetType {5}",
					                  par.ProcedureName, par.Name, par.Position, par.Direction, par.DbType, par.NetType);
				}
				
				
				ClassWriter cw = new ClassWriter(){
					Schema=fbd,
				};
				
				cw.WriteClass( new Table(){Name="EMPLOYEE"} );
				
				
				Console.WriteLine("This is The End my friend");
			
			//DTOGenerator
				
			}
			
			
			
			
		}
Exemplo n.º 6
0
        public static void Main(string[] args)
        {
            OrmLiteConfig.DialectProvider = new OracleOrmLiteDialectProvider();
            using (IDbConnection db =
                       "Data Source=x;User Id=x;Password=x;".OpenDbConnection())
                using (IDbCommand dbConn = db.CreateCommand())
                {
                    Schema fbd = new Schema()
                    {
                        Connection = db
                    };

                    ClassWriter cw = new ClassWriter()
                    {
                        Schema           = fbd,
                        GenerateMetadata = true,
                        //SpaceName= "your.app.namespace",
                        //OutputDirectory="outputpath"
                        //Usings="Using System;\nUsing System.Data\n"
                    };

                    foreach (var t in fbd.Tables)
                    {
                        Console.Write("Generating POCO Class for table:'{0}'...", t.Name);
                        cw.WriteClass(t);
                        Console.WriteLine(" Done.");
                    }
                    Console.WriteLine("---------------------------------");
                    Console.WriteLine("See classes in: '{0}'", cw.OutputDirectory);

                    //compilar ...
                    CompilerParameters cp = new CompilerParameters();
                    cp.GenerateExecutable = false;
                    cp.GenerateInMemory   = false;
                    cp.ReferencedAssemblies.AddRange(
                        new string[] {
                        "System.dll",
                        "System.ComponentModel.DataAnnotations.dll",
                        Path.Combine(Directory.GetCurrentDirectory(), "ServiceStack.OrmLite.dll"),
                        Path.Combine(Directory.GetCurrentDirectory(), "ServiceStack.Common.dll"),
                        Path.Combine(Directory.GetCurrentDirectory(), "ServiceStack.Interfaces.dll")
                    });
                    cp.OutputAssembly = Path.Combine(cw.OutputDirectory, cw.SpaceName + ".dll");

                    var providerOptions = new Dictionary <string, string>();
                    providerOptions.Add("CompilerVersion", "v3.5");

                    CodeDomProvider cdp = new CSharpCodeProvider(providerOptions);

                    string []       files = Directory.GetFiles(cw.OutputDirectory, "*.cs");
                    CompilerResults cr    = cdp.CompileAssemblyFromFile(cp, files);

                    if (cr.Errors.Count == 0)
                    {
                        Console.WriteLine("Generated file {0}", Path.Combine(cw.OutputDirectory, cw.SpaceName + ".dll"));
                    }
                    else
                    {
                        foreach (CompilerError ce in cr.Errors)
                        {
                            Console.WriteLine(ce.ErrorText);
                        }
                    }
                }


            Console.WriteLine("This is The End my friend!");
        }
Exemplo n.º 7
0
        public static void Main(string[] args)
        {
            OrmLiteConfig.DialectProvider = new FirebirdOrmLiteDialectProvider();


            using (IDbConnection db =
                       "User=SYSDBA;Password=masterkey;Database=employee.fdb;DataSource=localhost;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
            {
                Schema fbd = new Schema()
                {
                    Connection = db
                };

                Console.WriteLine("--------TABLES-------------");

                var tables = fbd.Tables;

                foreach (Table t in tables)
                {
                    Console.WriteLine(t.Name);
                }

                Console.WriteLine("-------users's owner--------------");


                Table t1 = fbd.GetTable("USERS");
                Console.WriteLine(t1.Owner);

                Console.WriteLine("---------user's columns ----------------");

                var Columns = fbd.GetColumns("USERS");

                foreach (Column cl in Columns)
                {
                    Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} ",
                                      cl.Name, cl.Position, cl.Nullable, cl.Length, cl.DbType, cl.NetType, cl.Sequence);
                }

                Console.WriteLine("--------------------------------------------");

                Console.WriteLine("EMPLOYEE's Columns ");

                Columns = fbd.GetColumns("EMPLOYEE");

                foreach (Column cl in Columns)
                {
                    Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} -- Computed {7} ",
                                      cl.Name, cl.Position, cl.Nullable, cl.Length, cl.DbType,
                                      cl.NetType, cl.Sequence, cl.IsComputed);
                }

                Columns = fbd.GetColumns("COMPANY");

                foreach (Column cl in Columns)
                {
                    Console.WriteLine("{0}--{1}--{2}--{3} -- {4}-- {5}--{6} ",
                                      cl.Name, cl.Position, cl.Nullable, cl.Length, cl.DbType, cl.NetType, cl.Sequence);
                }

                Console.WriteLine("--------------------------------------------");

                Console.WriteLine("-----------------Procedure---------------------------");

                Console.WriteLine("----- ADD_EMP_PROJ ----");

                Procedure p = fbd.GetProcedure("ADD_EMP_PROJ");
                Console.WriteLine("p.Name {0} p.Owner {1} p.Inputs {2} p.Outputs {3} p.Type {4}",
                                  p.Name, p.Owner, p.Inputs, p.Outputs, p.Type);

                var parameters = fbd.GetParameters(p);
                foreach (var par in parameters)
                {
                    Console.WriteLine("p.ProcedureName {0} p.Name {1} p.Position {2} p.ParameterType {3} p.DbType {4} p.NetType {5}",
                                      par.ProcedureName, par.Name, par.Position, par.Direction, par.DbType, par.NetType);
                }


                Console.WriteLine("----- ALL_LANGS ----");
                p = fbd.GetProcedure("ALL_LANGS");
                Console.WriteLine("p.Name {0} p.Owner {1} p.Inputs {2} p.Outputs {3} p.Type {4}",
                                  p.Name, p.Owner, p.Inputs, p.Outputs, p.Type);


                parameters = fbd.GetParameters(p);

                parameters = fbd.GetParameters(p);
                foreach (var par in parameters)
                {
                    Console.WriteLine("p.ProcedureName {0} p.Name {1} p.Position {2} p.ParameterType {3} p.DbType {4} p.NetType {5}",
                                      par.ProcedureName, par.Name, par.Position, par.Direction, par.DbType, par.NetType);
                }


                ClassWriter cw = new ClassWriter()
                {
                    Schema = fbd,
                };

                cw.WriteClass(new Table()
                {
                    Name = "EMPLOYEE"
                });


                Console.WriteLine("This is The End my friend");

                //DTOGenerator
            }
        }
Exemplo n.º 8
0
        public static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            Config.DialectProvider = new FirebirdDialectProvider();
            using (IDbConnection db =
                       //"User=SYSDBA;Password=masterkey;Database=MAQUINARIA.FDB;DataSource=172.16.7.40;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
                       ("User=SYSDBA;Password=masterkey;Database=employee.fdb;" +
                        "DataSource=localhost;Dialect=3;charset=ISO8859_1;").OpenDbConnection())

                //("User=SYSDBA;Password=masterkey;Database=/home/angel/bd/INTER2011/INTERNACIONAL2011.FDB;" +
                //	"DataSource=localhost;Dialect=3;charset=ISO8859_1;").OpenDbConnection())
                using (IDbCommand dbConn = db.CreateCommand())
                {
                    Schema fbd = new Schema()
                    {
                        Connection = db
                    };

                    ClassWriter cw = new ClassWriter()
                    {
                        Schema = fbd,
                    };

                    foreach (var t in fbd.Tables)
                    {
                        cw.WriteClass(t);
                    }

                    /*Table t = new Table(){Name=	"CONCEPTO"};
                     * cw.WriteClass(t);
                     */

                    //var materiales = dbConn.Select<Materialsuc>(" MATID='{0}' AND SUCID='{1}'", 9136,30) ;

                    /*
                     * var kardex = dbConn.Select<Kardex>(" NUMERO LIKE 'RMDT%' ORDER BY  NUMERO DESC ROWS 1 ") ;
                     * var r = kardex.FirstOrDefault();
                     * if( r != default(Kardex) )
                     * Console.WriteLine( r.Numero);
                     */

                    //var concepto = dbConn.Select<Concepto>(" CODIGO = '{0}' ROWS 1 ", "000292") ; //does not work !!!

                    /*var concepto = dbConn.Select<Concepto>( string.Format(" CODIGO = '{0}' ROWS 1 ", "000292") );
                     * var c = concepto.FirstOrDefault();
                     * if( c != default(Concepto) )
                     * Console.WriteLine( c.Descrip );
                     */

                    //Console.WriteLine(materiales.Count);
                    //Console.WriteLine("there is company with id:'{0}' ? {1}",
                    //                  5,
                    //                  dbConn.Exists<Company>( "Id='{0}'",5 ) );

                    //Console.WriteLine("there is company with id:'{0}' ? {1}",
                    //                  100,
                    //                  dbConn.Exists<Company>( "Id='{0}'",100 )) ;



                    Company cp = new Company {
                        Id = 5
                    };


                    Console.WriteLine("there is company with id:'{0}' ? {1}",
                                      cp.Id,
                                      dbConn.Exists <Company>(cp));

                    cp.Id = 100;
                    Console.WriteLine("there is company with id:'{0}' ? {1}",
                                      cp.Id,
                                      dbConn.Exists <Company>(cp));

                    Console.WriteLine(dbConn.HasChildren <Customer>(new Customer()
                    {
                        Id = 20
                    }));
                    Console.WriteLine(dbConn.HasChildren <Customer>(new Customer()
                    {
                        Id = 1001
                    }));

                    Customer cust = new Customer()
                    {
                        Id = 20
                    };

                    Console.WriteLine("Has customer with Id:'{0}' Children in Sales ? {1}",
                                      cust.Id,
                                      dbConn.HasChildren <Sales>(cust));
                    cust.Id = 1001;

                    Console.WriteLine("Has customer with Id:'{0}' Children in Sales ? {1}",
                                      cust.Id,
                                      dbConn.HasChildren <Sales>(cust));
                }


            Console.WriteLine("This is The End my friend!");
        }
Exemplo n.º 9
0
        public static void Main(string[] args)
        {
            Console.WriteLine ("Hello World!");

            Config.DialectProvider = new FirebirdDialectProvider();
            using (IDbConnection db =
                   //"User=SYSDBA;Password=masterkey;Database=MAQUINARIA.FDB;DataSource=172.16.7.40;Dialect=3;charset=ISO8859_1;".OpenDbConnection())
                   ("User=SYSDBA;Password=masterkey;Database=employee.fdb;" +
                   	"DataSource=localhost;Dialect=3;charset=ISO8859_1;").OpenDbConnection())

                   //("User=SYSDBA;Password=masterkey;Database=/home/angel/bd/INTER2011/INTERNACIONAL2011.FDB;" +
                   //	"DataSource=localhost;Dialect=3;charset=ISO8859_1;").OpenDbConnection())
            using ( IDbCommand dbConn = db.CreateCommand())
            {

                Schema fbd= new Schema(){
                    Connection = db
                };

                ClassWriter cw = new ClassWriter(){
                    Schema=fbd,
                };

                foreach(var t in fbd.Tables){
                    cw.WriteClass( t);
                }

                /*Table t = new Table(){Name=	"CONCEPTO"};
                cw.WriteClass(t);
                */

                //var materiales = dbConn.Select<Materialsuc>(" MATID='{0}' AND SUCID='{1}'", 9136,30) ;
                /*
                var kardex = dbConn.Select<Kardex>(" NUMERO LIKE 'RMDT%' ORDER BY  NUMERO DESC ROWS 1 ") ;
                var r = kardex.FirstOrDefault();
                if( r != default(Kardex) )
                   Console.WriteLine( r.Numero);
                */

                //var concepto = dbConn.Select<Concepto>(" CODIGO = '{0}' ROWS 1 ", "000292") ; //does not work !!!
                /*var concepto = dbConn.Select<Concepto>( string.Format(" CODIGO = '{0}' ROWS 1 ", "000292") );
                var c = concepto.FirstOrDefault();
                if( c != default(Concepto) )
                   Console.WriteLine( c.Descrip );
                */

                //Console.WriteLine(materiales.Count);
                //Console.WriteLine("there is company with id:'{0}' ? {1}",
                //                  5,
                //                  dbConn.Exists<Company>( "Id='{0}'",5 ) );

                //Console.WriteLine("there is company with id:'{0}' ? {1}",
                //                  100,
                //                  dbConn.Exists<Company>( "Id='{0}'",100 )) ;

                Company cp = new Company{Id=5};

                Console.WriteLine("there is company with id:'{0}' ? {1}",
                                  cp.Id,
                                  dbConn.Exists<Company>( cp ) );

                cp.Id=100;
                Console.WriteLine("there is company with id:'{0}' ? {1}",
                                  cp.Id,
                                  dbConn.Exists<Company>( cp )) ;

                Console.WriteLine(dbConn.HasChildren<Customer>(new Customer(){Id=20}) );
                Console.WriteLine(dbConn.HasChildren<Customer>(new Customer(){Id=1001}) );

                Customer cust =new Customer(){ Id=20};

                Console.WriteLine("Has customer with Id:'{0}' Children in Sales ? {1}",
                                  cust.Id,
                                  dbConn.HasChildren<Sales>(cust) );
                cust.Id=1001;

                Console.WriteLine("Has customer with Id:'{0}' Children in Sales ? {1}",
                                  cust.Id,
                                  dbConn.HasChildren<Sales>(cust) );

            }

            Console.WriteLine ("This is The End my friend!");
        }