Exemplo n.º 1
0
        // binds the table to database
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            _context = new BuildingContext();

            _context.Buildings.Load();

            buildingsBindingSource.DataSource = _context.Buildings.Local.Where(b => b.PlanetId == planetId).ToList();

            tb_planetName.Text      = planetName;
            tb_planetResources.Text = planetResource.ToString();
        }
Exemplo n.º 2
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     _context = new BuildingContext();
     // Call the Load method to get the data for the given DbSet
     // from the database.
     // The data is materialized as entities. The entities are managed by
     // the DbContext instance.
     _context.Planets.Load();
     // Bind the categoryBindingSource.DataSource to
     // all the Unchanged, Modified and Added Category objects that
     // are currently tracked by the DbContext.
     // Note that we need to call ToBindingList() on the
     // ObservableCollection<TEntity> returned by
     // the DbSet.Local property to get the BindingList<T>
     // in order to facilitate two-way binding in WinForms.
     this.planetBindingSource.DataSource = _context.Planets.Local.ToBindingList();
 }