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


C# Service1Client.UpdateDepartment方法代码示例

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


在下文中一共展示了Service1Client.UpdateDepartment方法的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: AddNewDepartmentAndCourses

        static void AddNewDepartmentAndCourses(int departmentID, int courseID)
        {
            using (var service = new Service1Client())
            {
                Department newDepartment = new Department()
                {
                    DepartmentID = departmentID,
                    Budget = 13000.000m,
                    Name = "New Department",
                    StartDate = DateTime.Now
                };

                OnlineCourse newCourse = new OnlineCourse()
                {
                    CourseID = courseID,
                    DepartmentID = departmentID,
                    URL = "http://www.fineartschool.net/Trigonometry",
                    Title = "New Onsite Course",
                    Credits = 4
                };

                // Add the course to the department.
                newDepartment.Courses.Add(newCourse);

                // The newly create objects are marked as added, the service will insert these into the store.
                service.UpdateDepartment(newDepartment);

                // Let’s make few more changes to the saved object.
                // Since the previous changes have now been persisted, call AcceptChanges to
                // reset the ChangeTracker on the objects and mark the state as ObjectState.Unchanged.
                // Note, AcceptChanges sets the tracking on, so you do not need to call StartTracking
                // explicitly.
                newDepartment.AcceptChanges();
                newCourse.AcceptChanges();

                // Because the change tracking is enabled
                // the following change will set newCourse.ChangeTracker.State to ObjectState.Modified.
                newCourse.Credits = 6;
                service.UpdateDepartment(newDepartment);

            }
        }
开发者ID:szarnyasg,项目名称:BUTE-Class-Administration-System,代码行数:42,代码来源:Program.cs

示例3: buttonSave_Click

        private void buttonSave_Click(object sender, RoutedEventArgs e)
        {
            using (var service = new Service1Client())
            {
                // Save all the departments and their courses.
                foreach (var department in departments)
                {
                    service.UpdateDepartment(department);

                    // Call AcceptChanges on all the objects
                    // to resets the change tracker and set the state of the objects to Unchanged.
                    department.AcceptChanges();
                    foreach (var course in department.Courses)
                        course.AcceptChanges();
                }
            }
        }
开发者ID:szarnyasg,项目名称:BUTE-Class-Administration-System,代码行数:17,代码来源:MainWindow.xaml.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.UpdateDepartment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。