当前位置: 首页>>代码示例>>C#>>正文


C# Service1Client.GetDepartments方法代码示例

本文整理汇总了C#中Service1Client.GetDepartments方法的典型用法代码示例。如果您正苦于以下问题:C# Service1Client.GetDepartments方法的具体用法?C# Service1Client.GetDepartments怎么用?C# Service1Client.GetDepartments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Service1Client的用法示例。


在下文中一共展示了Service1Client.GetDepartments方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeleteDepartmentAndCourses

        static void DeleteDepartmentAndCourses(int departmentID)
        {
            using (var service = new Service1Client())
            {
                List<Department> departments = service.GetDepartments();

                Department department = departments.Single(d => d.DepartmentID == departmentID);

                // When MarkAsDeleted is called, the entity is removed from the collection,
                // if we modify the collection over which foreach is looping an exception will be thrown.
                // That is why we need to make a copy of the courses collection by
                // calling department.Courses.ToList();
                List<Course> courses = department.Courses.ToList();
                foreach (var c in courses)
                {

                    // Marks each comment for the post as Deleted.
                    // If another entity have a foreign key relationship with this Course object
                    // an exception will be thrown during save operation.
                    c.MarkAsDeleted();
                }

                department.MarkAsDeleted();
                service.UpdateDepartment(department);
            }
        }
开发者ID:szarnyasg,项目名称:BUTE-Class-Administration-System,代码行数:26,代码来源:Program.cs

示例2: Window_Loaded

 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     using (var service = new Service1Client())
     {
         // Set the parent of of your data bound controls to the root of the graph.
         // In the xaml page the appropriate paths should be set on each data bound control.
         // For the comboBoxDepartment it is empty because it is bound to Departments (which is root).
         // For the listViewItems it is set to Courses because it is bound to Department.Courses.
         // Note, that the TextBox controls are embedded in the two of the columns in the listViewItems.
         // This is done to enable editing in the ListView control.
         departments = service.GetDepartments();
         this.departmentsItemsGrid.DataContext = departments;
     }
 }
开发者ID:szarnyasg,项目名称:BUTE-Class-Administration-System,代码行数:14,代码来源:MainWindow.xaml.cs

示例3: DisplayDepartmentsAndCourses

 // <snippetSTESchoolModelTestAll>
 static void DisplayDepartmentsAndCourses()
 {
     using (var service = new Service1Client())
     {
         // Get all the departments.
         List<Department> departments = service.GetDepartments();
         foreach (var d in departments)
         {
             Console.WriteLine("ID: {0}, Name: {1}", d.DepartmentID, d.Name);
             // Get all the courses for each department.
             // The reason we are able to access
             // the related courses is because the service eagrly loaded the related objects
             // (using the System.Data.Objects.ObjectQuery(T).Include method).
             foreach (var c in d.Courses.OfType<OnlineCourse>())
             {
                 Console.WriteLine("  OnLineCourse ID: {0}, Title: {1}", c.CourseID, c.Title);
             }
             foreach (var c in d.Courses.OfType<OnsiteCourse>())
             {
                 Console.WriteLine("  OnSiteCourse ID: {0}, Title: {1}", c.CourseID, c.Title);
             }
         }
     }
 }
开发者ID:szarnyasg,项目名称:BUTE-Class-Administration-System,代码行数:25,代码来源:Program.cs

示例4: UpdateDepartmentAndCourses

        static void UpdateDepartmentAndCourses(int departmentID, int courseID)
        {
            using (var service = new Service1Client())
            {
                // Get all the departments.
                List<Department> departments = service.GetDepartments();
                // Use LINQ to Objects to query the departments collection
                // for the specific department object.
                Department department = departments.Single(d => d.DepartmentID == departmentID);
                department.Budget = department.Budget - 1000.00m;

                // Get the specified course that belongs to the department.
                // The reason we are able to access the related course
                // is because the service eagrly loaded the related objects
                // (using the System.Data.Objects.ObjectQuery(T).Include method).
                Course existingCourse = department.Courses.Single(c => c.CourseID == courseID);
                existingCourse.Credits = 3;

                service.UpdateDepartment(department);
            }
        }
开发者ID:szarnyasg,项目名称:BUTE-Class-Administration-System,代码行数:21,代码来源:Program.cs


注:本文中的Service1Client.GetDepartments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。