Exemplo n.º 1
0
 private void getDepartment()
 {
     //connect to Entity Framework Database
     using (ContosoContext db = new ContosoContext())
     {
         //query the department data
         var department = (from alldepartment in db.Departments
                           select alldepartment);
         // bind the resultset to the student grid
         DepartmentGridView.DataSource = department.ToList();
         DepartmentGridView.DataBind();
     }
 }
        private void FetchDepartments()
        {
            string sortString = Session["SortColumn"] + " " + Session["SortDirection"];

            using (DefaultConnection db = new DefaultConnection())
            {
                var departments = (from departmentList in db.Departments
                                   select departmentList);

                //DepartmentGridView.DataSource = departments.ToList();
                DepartmentGridView.DataSource = departments.AsQueryable().OrderBy(sortString).ToList();
                DepartmentGridView.DataBind();
            }
        }
Exemplo n.º 3
0
        /**
         * <summary>
         * This method gets the Department data from the DB
         * </summary>
         *
         * @method Getdepartment
         * @returns {void}
         */
        protected void GetDepartment()
        {
            string sortString = Session["SortColumn"].ToString() + " " + Session["SortDirection"].ToString();

            // connect to EF
            using (DefaultConnection db = new DefaultConnection())
            {
                // query the Department Table using EF and LINQ
                var Department = (from allDepartments in db.Departments
                                  select allDepartments);

                // bind the result to the GridView
                DepartmentGridView.DataSource = Department.AsQueryable().OrderBy(sortString).ToList();
                DepartmentGridView.DataBind();
            }
        }