示例#1
0
        public void DeleteItem()
        {
            DataServiceContext ctx = new DataServiceContext(new Uri("http://localhost/Chapter9/MovieService.svc"));

            MovieService.Film FilmToDelete =
                ctx.Execute <MovieService.Film>(new Uri("Films(1)", UriKind.Relative)).First();
            ctx.DeleteObject(FilmToDelete);
            ctx.SaveChanges();
        }
示例#2
0
        public void AddNewItem()
        {
            DataServiceContext ctx = new DataServiceContext(new Uri("http://localhost/Chapter9/MovieService.svc"));

            MovieService.Film NewFilm = new MovieService.Film();
            NewFilm.Title       = "Pulp Fiction";
            NewFilm.Length      = 124;
            NewFilm.Description = "Quentins classic movie";
            ctx.AddObject("Films", NewFilm);
            ctx.SaveChanges();
        }