partial void OnTaskChanged(Task value);
public void ManyToOneAndOneToMany() { int taskId; using (var db = new TrackerDataContext()) { var priority = db.Priority.GetByKey(Priority.High); var status = db.Status.GetByKey(Status.Completed); var user = db.User.GetByKey(UserId); var task = new Task { CompleteDate = DateTime.Now, CreatedDate = DateTime.Now, Details = "Test'n", DueDate = DateTime.Now, ModifiedDate = DateTime.Now, Priority = priority, StartDate = DateTime.Now, Status = status, Summary = "Test'n", UserCreated = user }; db.Task.InsertOnSubmit(task); db.SubmitChanges(); taskId = task.Id; } using (var db = new TrackerDataContext()) { var user = db.User.GetByKey(UserId); Assert.AreEqual(0, user.TaskAssignedList.Count); Assert.AreEqual(1, user.TaskCreatedList.Count); var task = user.TaskCreatedList.First(); user.TaskAssignedList.Add(task); db.SubmitChanges(); Assert.AreEqual(1, user.TaskAssignedList.Count); } using (var db = new TrackerDataContext()) { var task = db.Task.GetByKey(taskId); db.Task.DeleteOnSubmit(task); db.SubmitChanges(); var user = db.User.GetByKey(UserId); Assert.AreEqual(0, user.TaskAssignedList.Count); Assert.AreEqual(0, user.TaskCreatedList.Count); } }
partial void OnTaskChanging(Task newValue, Task oldValue);