コード例 #1
0
        static void Main(string[] args)
        {
            MongoServer   server;
            MongoDatabase moviesDb;

            server   = MongoServer.Create();
            moviesDb = server.GetDatabase("movies_db");

            //Create some data
            var movie1 = new Movie {
                Title = "Indiana Jones and the Raiders of the Lost Ark", Year = "1981"
            };

            movie1.AddActor("Harrison Ford");
            movie1.AddActor("Karen Allen");
            movie1.AddActor("Paul Freeman");

            var movie2 = new Movie {
                Title = "Star Wars: Episode IV - A New Hope", Year = "1977"
            };

            movie2.AddActor("Mark Hamill");
            movie2.AddActor("Harrison Ford");
            movie2.AddActor("Carrie Fisher");

            var movie3 = new Movie {
                Title = "Das Boot", Year = "1981"
            };

            movie3.AddActor("Jürgen Prochnow");
            movie3.AddActor("Herbert Grönemeyer");
            movie3.AddActor("Klaus Wennemann");

            //Insert the movies into the movies_collection
            var moviesCollection = moviesDb.GetCollection <Movie>("movies_collection");
            //moviesCollection.Insert(movie1);
            //moviesCollection.Insert(movie2);
            //moviesCollection.Insert(movie3);

            var query = Query.EQ("Year", "1981");

            var movieFound = moviesDb.GetCollection <Movie>("movies_collection").Drop();
        }
コード例 #2
0
 protected override void AddData(ISessionFactory sessionFactory)
 {
     using (var session = sessionFactory.OpenSession())
     {
         using (var tx = session.BeginTransaction())
         {
             for (var i = 1; i <= 20; i++)
             {
                 var movie = new Movie
                 {
                     Name      = "Movie" + i,
                     UnitPrice = i
                 };
                 movie.AddActor("Actor" + i, "Role" + i);
                 movie.AddActor("Second Actor" + 1, "Second Role" + i);
                 session.Save(movie);
             }
             tx.Commit();
         }
     }
 }
コード例 #3
0
ファイル: MovieRepository.cs プロジェクト: Waffe/MMDB3
        public void LoadDataByCode()
        {
            CastOrCrewRepository castOrCrewRepository = CastOrCrewRepository.Instance;

            var denzelwashington  = new CastOrCrew("Denzel Washington", new DateTime(1954, 12, 28));
            var robertdeniro      = new CastOrCrew("Robert De Niro", new DateTime(1943, 8, 17));
            var alpacino          = new CastOrCrew("Al Pacino", new DateTime(1940, 4, 25));
            var tomhanks          = new CastOrCrew("Tom Hanks", new DateTime(1956, 7, 9));
            var natalieportman    = new CastOrCrew("Natalie Portman", new DateTime(1981, 6, 9));
            var markruffalo       = new CastOrCrew("Mark Ruffalo", new DateTime(1967, 11, 22));
            var leonardodicaprio  = new CastOrCrew("Leonardo DiCaprio", new DateTime(1974, 11, 11));
            var johnnydepp        = new CastOrCrew("Johnny Depp", new DateTime(1963, 6, 9));
            var edwardnorton      = new CastOrCrew("Edward Norton", new DateTime(1969, 8, 18));
            var bradpitt          = new CastOrCrew("Brad Pitt", new DateTime(1963, 12, 18));
            var keiraknightley    = new CastOrCrew("Keira Knightley", new DateTime(1985, 3, 26));
            var joepesci          = new CastOrCrew("Joe Pesci", new DateTime(1943, 2, 9));
            var morhanfreeman     = new CastOrCrew("Morhan Freeman", new DateTime(1937, 6, 1));
            var keanureeves       = new CastOrCrew("Keanu Reeves", new DateTime(1964, 9, 2));
            var laurencefishburne = new CastOrCrew("Laurence Fishburne", new DateTime(1961, 7, 30));
            var samuelljackson    = new CastOrCrew("Samuel L Jackson", new DateTime(1948, 12, 21));
            var johntravolta      = new CastOrCrew("John Travolta", new DateTime(1954, 2, 18));
            var brucewillis       = new CastOrCrew("Bruce Willis", new DateTime(1955, 3, 19));
            var antoinefuqua      = new CastOrCrew("Antoine Fuqua", new DateTime(1966, 1, 19));
            var ronhoward         = new CastOrCrew("Ron Howard", new DateTime(1954, 3, 1));
            var martinscorsese    = new CastOrCrew("Martin Scorsese", new DateTime(1942, 11, 17));
            var johncarney        = new CastOrCrew("John Carney", new DateTime(1972, 1, 1));
            var davidfincher      = new CastOrCrew("David Fincher", new DateTime(1962, 8, 28));
            var lanawachowski     = new CastOrCrew("Lana Wachowski", new DateTime(1965, 6, 21));
            var lillywachowski    = new CastOrCrew("Lilly Wachowski", new DateTime(1969, 12, 29));
            var quentintarantino  = new CastOrCrew("Quentin Tarantino", new DateTime(1963, 3, 27));
            var johnmctiernan     = new CastOrCrew("John McTiernan", new DateTime(1951, 1, 8));

            castOrCrewRepository.Add(denzelwashington);
            castOrCrewRepository.Add(robertdeniro);
            castOrCrewRepository.Add(alpacino);
            castOrCrewRepository.Add(tomhanks);
            castOrCrewRepository.Add(natalieportman);
            castOrCrewRepository.Add(markruffalo);
            castOrCrewRepository.Add(leonardodicaprio);
            castOrCrewRepository.Add(johnnydepp);
            castOrCrewRepository.Add(edwardnorton);
            castOrCrewRepository.Add(bradpitt);
            castOrCrewRepository.Add(keiraknightley);
            castOrCrewRepository.Add(joepesci);
            castOrCrewRepository.Add(morhanfreeman);
            castOrCrewRepository.Add(keanureeves);
            castOrCrewRepository.Add(laurencefishburne);
            castOrCrewRepository.Add(samuelljackson);
            castOrCrewRepository.Add(johntravolta);
            castOrCrewRepository.Add(brucewillis);
            castOrCrewRepository.Add(antoinefuqua);
            castOrCrewRepository.Add(ronhoward);
            castOrCrewRepository.Add(martinscorsese);
            castOrCrewRepository.Add(johncarney);
            castOrCrewRepository.Add(davidfincher);
            castOrCrewRepository.Add(lanawachowski);
            castOrCrewRepository.Add(lillywachowski);
            castOrCrewRepository.Add(quentintarantino);
            castOrCrewRepository.Add(johnmctiernan);

            var trainingday   = new Movie("Training Day", new ProductionYear(2001));
            var inferno       = new Movie("Inferno", new ProductionYear(2016));
            var shutterisland = new Movie("Shutter Island", new ProductionYear(2010));
            var goodfellas    = new Movie("Goodfellas", new ProductionYear(1990));
            var beginagain    = new Movie("Begin Again", new ProductionYear(2013));
            var fightclub     = new Movie("Fight Club", new ProductionYear(1999));
            var matrix        = new Movie("Matrix", new ProductionYear(1999));
            var pulpfiction   = new Movie("Pulp Fiction", new ProductionYear(1994));
            var diehard       = new Movie("Die Hard", new ProductionYear(1988));

            AddMovie(trainingday);
            AddMovie(inferno);
            AddMovie(shutterisland);
            AddMovie(goodfellas);
            AddMovie(beginagain);
            AddMovie(fightclub);
            AddMovie(matrix);
            AddMovie(pulpfiction);
            AddMovie(diehard);

            trainingday.AddDirector(antoinefuqua);
            trainingday.AddActor(denzelwashington);
            inferno.AddDirector(ronhoward);
            inferno.AddActor(tomhanks);
            shutterisland.AddDirector(martinscorsese);
            shutterisland.AddActor(markruffalo);
            shutterisland.AddActor(leonardodicaprio);
            goodfellas.AddDirector(martinscorsese);
            goodfellas.AddActor(robertdeniro);
            goodfellas.AddActor(joepesci);
            beginagain.AddDirector(johncarney);
            beginagain.AddActor(markruffalo);
            beginagain.AddActor(keiraknightley);
            fightclub.AddDirector(davidfincher);
            fightclub.AddActor(edwardnorton);
            fightclub.AddActor(bradpitt);
            matrix.AddDirector(lanawachowski);
            matrix.AddDirector(lillywachowski);
            matrix.AddActor(keanureeves);
            matrix.AddActor(laurencefishburne);
            pulpfiction.AddDirector(quentintarantino);
            pulpfiction.AddActor(samuelljackson);
            pulpfiction.AddActor(johntravolta);
            pulpfiction.AddActor(brucewillis);
            diehard.AddDirector(johnmctiernan);
            diehard.AddActor(brucewillis);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: beqasmile/BSOOP1
        static void Main(string[] args)
        {
            List<Movie> myMoviesList = new List<Movie>(); // list creation and definition

            for (int i = 0; i < 5; i++)
            {
                Movie myMovie = new Movie(i);


                Console.WriteLine("Please input movie name >");
                String movieName = Console.ReadLine();
                myMovie.SetMovieName(movieName);
                Console.WriteLine("Please input movie type >");
                String movieType = Console.ReadLine();
                myMovie.SetMovieType(movieType);
                Console.WriteLine("Please input movie lenght >");

                int movieLength = int.Parse(Console.ReadLine());
                myMovie.SetMovieLength(movieLength);
                Console.WriteLine("Please input movie director >");

                String movieDirector = Console.ReadLine();
                MovieDirector md1 = new MovieDirector(movieDirector);
                myMovie.SetMovieDirector(md1);


                Console.WriteLine("Please input the number of actors>");
                int numberActors = int.Parse(Console.ReadLine());


                for (int j = 0; j < numberActors; j++)
                {
                    Console.WriteLine("Please input actor name ");
                    string actorName = Console.ReadLine();

                    Console.WriteLine("Please input actor sur name ");
                    string actorSUrName = Console.ReadLine();


                    Console.WriteLine("Please input actor type ");
                    string actorType = Console.ReadLine();


                    int birthDay = int.Parse(Console.ReadLine());
                    Console.WriteLine("Please input bitrhday >");

                    MovieActor movieActor = new MovieActor(i, actorName, actorSUrName, birthDay, actorType);

                    myMovie.AddActor(movieActor);

                }


                myMoviesList.Add(myMovie);


            }


            // myMoviesList.Remove(movie1);                   // remove object from list

            foreach (Movie movieTemp in myMoviesList)       // pass over list
            {
                Console.WriteLine(movieTemp.ToString());
            }

            Console.ReadKey();

        }