コード例 #1
0
ファイル: MainPage.xaml.cs プロジェクト: ProgRx/Chapter-6
        void CreateBook_Click( object sender, RoutedEventArgs e )
        {
            BooksDataContext db = new BooksDataContext( "isostore:/bookDB.sdf" );
            Progress.Items.Add("Connected to bookDB.sdf...");

            Publisher pub = new Publisher()
            {
                PublisherID = "1",
                Name = "APress",
                City = "Acton",
                Url = "http://Apress.com"
            };
            db.Publishers.InsertOnSubmit( pub );
            Progress.Items.Add( "Pub (Apress) created..." );

            Publisher pub2 = new Publisher()
            {
                PublisherID = "2",
                Name = "O'Reilly",
                City = "Cambridge",
                Url = "http://Oreilly.com"
            };
            db.Publishers.InsertOnSubmit( pub );
            Progress.Items.Add( "Pub (O'Reilly) created..." );

            Book theBook = new Book()
            {
                BookID = "1",
                BookPublisher = pub,
                PublicationDate = DateTime.Now,
                Title = "Programming Reactive Extensions"
            };
            db.Books.InsertOnSubmit( theBook );
            Progress.Items.Add( "Book (Rx) created..." );

            theBook = new Book()
            {
                BookID = "2",
                BookPublisher = pub,
                PublicationDate = DateTime.Now,
                Title="Migrating to Windows Phone"
            };
            db.Books.InsertOnSubmit( theBook );
            Progress.Items.Add( "Book (Migrating) created..." );

            theBook = new Book()
            {
                BookID = "3",
                BookPublisher = pub2,
                PublicationDate = DateTime.Now,
                Title = "Programming C#"
            };
            db.Books.InsertOnSubmit( theBook );
            Progress.Items.Add( "Book (C#) created..." );

            db.SubmitChanges();
            Progress.Items.Add( "DB Updated." );
            Progress.SelectedIndex = Progress.Items.Count -1;
        }
コード例 #2
0
        void CreateBook_Click(object sender, RoutedEventArgs e)
        {
            BooksDataContext db = new BooksDataContext("isostore:/bookDB.sdf");

            Progress.Items.Add("Connected to bookDB.sdf...");

            Publisher pub = new Publisher()
            {
                PublisherID = "1",
                Name        = "APress",
                City        = "Acton",
                Url         = "http://Apress.com"
            };

            db.Publishers.InsertOnSubmit(pub);
            Progress.Items.Add("Pub (Apress) created...");



            Publisher pub2 = new Publisher()
            {
                PublisherID = "2",
                Name        = "O'Reilly",
                City        = "Cambridge",
                Url         = "http://Oreilly.com"
            };

            db.Publishers.InsertOnSubmit(pub);
            Progress.Items.Add("Pub (O'Reilly) created...");



            Book theBook = new Book()
            {
                BookID          = "1",
                BookPublisher   = pub,
                PublicationDate = DateTime.Now,
                Title           = "Programming Reactive Extensions"
            };

            db.Books.InsertOnSubmit(theBook);
            Progress.Items.Add("Book (Rx) created...");



            theBook = new Book()
            {
                BookID          = "2",
                BookPublisher   = pub,
                PublicationDate = DateTime.Now,
                Title           = "Migrating to Windows Phone"
            };
            db.Books.InsertOnSubmit(theBook);
            Progress.Items.Add("Book (Migrating) created...");

            theBook = new Book()
            {
                BookID          = "3",
                BookPublisher   = pub2,
                PublicationDate = DateTime.Now,
                Title           = "Programming C#"
            };
            db.Books.InsertOnSubmit(theBook);
            Progress.Items.Add("Book (C#) created...");



            db.SubmitChanges();
            Progress.Items.Add("DB Updated.");
            Progress.SelectedIndex = Progress.Items.Count - 1;
        }