I need
some assistance deep saving many-to-many relationships. I'm using .netTiers v2.0.0.387.
I created an
extremely simple case where I have three tables: Student (StudentID int PK,
Name varchar(50)), Teacher(TeacherID int PK, Name varchar(50)), and
StudentTeacher(StudentID int PK, TeacherID int PK).
I run the
following code but the StudentTeacher junction table is never populated
(Student and Teacher tables are populated OK):
//
create a new teacher and save
Teacher t = new Teacher();
t.Name = "Teacher1";
DataRepository.TeacherProvider.Save(t);
//
create a new student
Student s = new Student();
s.Name = "Student1";
//
add teacher to the student's teacher collection
s.TeacherCollection_From_StudentTeacher.Add(t);
//
add student/teacher to the junction table
StudentTeacher st = new StudentTeacher();
st.TeacherID =
t.TeacherID;
s.StudentTeacherCollection.Add(st);
//
deep save the student
DataRepository.StudentProvider.DeepSave(s,
DeepSaveType.IncludeChildren, new Type[] { typeof(TList<Teacher>), typeof(TList<StudentTeacher>)
});
Any assistance would be appreciated. Thanks.
Mike