public List<Multiplex> GetMultiplexes() { using (var db = new MovieDataContext()) { return db.Multiplexes.ToList(); } }
public List<Movie> GetMovies(int multiplexId) { using (var db = new MovieDataContext()) { return db.Movies.Where(x => x.MultiplexId == multiplexId).ToList(); } }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { using (var db = new MovieDataContext()) { if (!db.DatabaseExists()) db.CreateDatabase(); } }
public void SaveMovies(List<Movie> items, int multiplexId) { using (var db = new MovieDataContext()) { db.Movies.DeleteAllOnSubmit(db.Movies.Where(x => x.MultiplexId == multiplexId)); db.SubmitChanges(); db.Movies.InsertAllOnSubmit(items); db.SubmitChanges(); } }
public void SaveMultiplexes(List<Multiplex> items) { using (var db = new MovieDataContext()) { db.Multiplexes.DeleteAllOnSubmit(db.Multiplexes); db.SubmitChanges(); db.Multiplexes.InsertAllOnSubmit(items); db.SubmitChanges(); } }