コード例 #1
0
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            //Initialize the ObjectContext
            schoolContext = new SchoolEntities();

            // Define a query that returns all Department
            // objects and course objects, ordered by name.
            var departmentQuery = from d in schoolContext.Departments.Include("Courses")
                                  orderby d.Name
                                  select d;

            try
            {
                // Bind the ComboBox control to the query,
                // which is executed during data binding.
                // To prevent the query from being executed multiple times during binding,
                // it is recommended to bind controls to the result of the Execute method.
                this.departmentList.DisplayMember = "Name";
                //this.departmentList.DataSource = ((ObjectQuery)departmentQuery).Execute(MergeOption.AppendOnly);
                this.departmentList.DataSource = departmentQuery.ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #2
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;
        }
コード例 #3
0
        private void Enrollment_Load(object sender, EventArgs e)
        {
            //Initialize the ObjectContext.
            schoolContext = new SchoolEntities();

            //Define a quert that returns all Deparment objects and
            //related Course objects, ordered by name.
            ObjectQuery <Department> departmentQuery = schoolContext.Departments.Include("Courses")
                                                       .OrderBy("it.Name");

            //Bind the Combox control to the query.
            this.departmentList.DataSource = departmentQuery
                                             .Execute(MergeOption.OverwriteChanges);
            this.departmentList.DisplayMember = "Name";
        }
コード例 #4
0
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();
            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);
            }
        }
コード例 #5
0
        private void OfficeAssignment_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();
            //Bet Persons of type Instructor.
            ObjectQuery <Instructor> instructorQuery = schoolContext.People.OfType <Instructor>();

            //Bind the query results to the GridView Control.
            //Display only location and name.
            officeGridView.DataSource = instructorQuery.Execute(MergeOption.OverwriteChanges);
            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;
        }
コード例 #6
0
        private void OfficeAssignment_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();
            //Bet Persons of type Instructor.
            ObjectQuery<Instructor> instructorQuery = schoolContext.People.OfType<Instructor>();

            //Bind the query results to the GridView Control.
            //Display only location and name.
            officeGridView.DataSource = instructorQuery.Execute(MergeOption.OverwriteChanges);
            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;
        }
コード例 #7
0
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();
            var departmentQuery =
                from d in schoolContext.Department.Include("Course") orderby d.Name select d;

            try
            {
                this.departmentList.DisplayMember = "Name";
                this.departmentList.DataSource    = departmentQuery.ToList();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #8
0
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();

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

            try
            {
                this.departmentList.DisplayMember = "Name";
                this.departmentList.DataSource    = ((ObjectQuery <Department>)departmentQuery).Execute(MergeOption.AppendOnly);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
コード例 #9
0
ファイル: CourseViewer.cs プロジェクト: emactaggart/CS476
        private void CourseViewer_Load(object sender, EventArgs e)
        {
            schoolContext = new SchoolEntities();

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

            try
            {
                this.departmentList.DisplayMember = "Name";
                this.departmentList.DataSource = departmentQuery.ToList();
                courseGridView.DataSource = departmentQuery.ToList();

                //this is from the tutorial and does not work
                //this.departmentList.DataSource = ((ObjectQuery)departmentQuery).Execute(MergeOption.AppendOnly);

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }