public Form1() { InitializeComponent(); using (var db = new LibraryDZ2Entities()) { listBox2.Items.AddRange(db.Authors.ToArray()); } }
private void btFind_Click(object sender, EventArgs e) { listBox1.Items.Clear(); using (var db = new LibraryDZ2Entities()) { foreach (var books in db.Authors.Where(p => p.Name.Contains(tbFind.Text)).ToList().Select(p => p.Books)) { listBox1.Items.AddRange(books.ToArray()); } } }