コード例 #1
0
 private void LaadListbox()
 {
     using (oefeningEntities ctx = new oefeningEntities())
     {
         var query = ctx.Persoons.Select(p => new { p, naam = p.Voornaam + " " + p.Achternaam }).ToList();
         lbPersonen.DataSource    = query;
         lbPersonen.DisplayMember = "naam";
         lbPersonen.ValueMember   = "p";
     }
 }
コード例 #2
0
        private void UpdateLists()
        {
            using (oefeningEntities ctx = new oefeningEntities())
            {
                var coupledbadges = ctx.badges.Join(ctx.PersoonBadges,
                                                    b => b.id,
                                                    pb => pb.badge,
                                                    (b, pb) => new { b, pb, Opschrift = b.Opschrift }
                                                    );

                lbxCurrentBadges.DisplayMember = "Opschrift";
                lbxCurrentBadges.DataSource    = coupledbadges.Where(x => x.pb.Persoon == selectedPersoon.id).ToList();
            }
        }
コード例 #3
0
        private void btnToevoegen_Click(object sender, EventArgs e)
        {
            NieuwPersoon np = new NieuwPersoon();

            if (np.ShowDialog() == DialogResult.OK)
            {
                using (oefeningEntities ctx = new oefeningEntities())
                {
                    ctx.Persoons.Add(np.persoon);
                    ctx.SaveChanges();
                    LaadListbox();
                }
            }
        }
コード例 #4
0
        private void Form1_Load(object sender, EventArgs e)
        {
            using (oefeningEntities ctx = new oefeningEntities())
            {
                var joinQuery = ctx.Persoons
                                .Join(ctx.PersoonBadges,
                                      p => p.id,
                                      pb => pb.id,
                                      (p, pb) => new { p, pb })
                                .Join(ctx.badges,
                                      pb2 => pb2.pb.id,
                                      b => b.id,
                                      (pb2, b) => new { pb2, b });
            }

            LaadListbox();
        }