Пример #1
0
            /// <summary>
            /// getVersionControls will throw if failure!
            /// </summary>
            /// <returns></returns>
            public override List <VersionControl> getVersionControls()
            {
                this.versioncontrols.Clear();

                var runner  = new CommandRunner(dbConnection);
                var results = runner.ExecuteDynamic("select * from public.versioncontrol", null);

                foreach (var d in results)
                {
                    this.versioncontrols.Add(new VersionControl {
                        id   = d.id,
                        ts   = d.ts,
                        name = d.name
                    });
                }
                return(this.versioncontrols as List <VersionControl>);
            }
Пример #2
0
        static void Main(string[] args)
        {
            var db = new CommandRunner("dvds");

            var q = new RegisterCommand(db);

            q.Email        = "*****@*****.**";
            q.Password     = "******";
            q.Confirmation = "password";
            q.First        = "Nick";
            q.Last         = "Shoup";
            var result = q.Execute();

            Console.WriteLine(result.Message, result.NewUserId, result.Status);


            var qAuth = new AuthenticateCommand(db);

            qAuth.ProviderKey   = "*****@*****.**";
            qAuth.ProviderValue = "password";

            var authResult = qAuth.Execute();

            Console.WriteLine(authResult.Message, authResult.UserID);

            var query = new RawSalesByDate(db);

            query.Year = 2007;
            var sales = query.Execute();

            foreach (var sale in sales)
            {
                //Console.WriteLine(sale.Title);
            }

            var films = db.Execute <Film>("select * from film");

            foreach (var film in films)
            {
                // Console.WriteLine(film.Title);
            }


            var filmsDynamic = db.ExecuteDynamic("select * from film");

            foreach (var film in filmsDynamic)
            {
                // Console.WriteLine(film.title);
            }



            //var cmd = db.BuildCommand("insert into actor(first_name, last_name, last_update) values (@0, @1, @2)", "Nick", "Shoup", DateTime.Now);

            //var resulsts = db.Transact(cmd);
            //foreach (var result in resulsts)
            //{
            //    Console.WriteLine(result);
            //}

            var actorQuery = new ActorQuery(db);

            actorQuery.ActorId = 3;
            var actors = actorQuery.Execute();

            Console.WriteLine(actors.Fullname);
            foreach (var film in actors.Films)
            {
                // Console.WriteLine(film.Title) ;
            }

            var actor1 = new Actor()
            {
                First = "Woody", Last = "Harrelson"
            };
            var actor2 = new Actor()
            {
                First = "Joe", Last = "Biff"
            };
            var actor3 = new Actor()
            {
                First = "Jolene", Last = "Silidkdk"
            };

            var qCommand = new Commands.Actors.AddBatchOfActors(db);

            qCommand.Actors = new Actor[] { actor1, actor2, actor3 };
            qCommand.Execute();
            Console.Read();
        }
Пример #3
0
 public IEnumerable <dynamic> runSqlDynamic(string sql)
 {
     var runner = new CommandRunner(dbConnection); return(runner.ExecuteDynamic(sql, null));
 }