Пример #1
0
        private void OfficeAssignment_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();

            var instrQuery = schoolContext.People.OfType <Instructor>();

            officeGridView.DataSource = instrQuery.ToList();

            officeGridView.Columns["HireDate"].Visible       = false;
            officeGridView.Columns["Timestamp"].Visible      = false;
            officeGridView.Columns["PersonID"].Visible       = false;
            officeGridView.Columns["EnrollmentDate"].Visible = false;
            officeGridView.Columns["StudentGrades"].Visible  = false;
            officeGridView.Columns["Courses"].Visible        = false;
        }
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();

            var departments = from d in schoolContext.Departments.Include("Courses")
                              orderby d.Name
                              select d;

            //var departments = schoolContext.Departments.Include(x => x.Courses).OrderBy(x => x.Name);
            try
            {
                this.departmentList.DisplayMember = "Name";
                this.departmentList.DataSource    = departments.ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }