コード例 #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;
        }
コード例 #2
0
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();

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

            try
            {
                departmentList.DataSource    = departments.ToList();
                departmentList.DisplayMember = "Name";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }