thank you very much for your answer
i use LINQ and WPF-C# not T-SQl !
the solution that i already use works but i want to know if it is technically OK and best for LINQ C# ?
public static void InsertOrUpdateTeacher( string Name,string Family
,string Licence , byte[] Bytes,List<lesson> Lessons)
{
DataClassesDataContext dc = new DataClassesDataContext();
Table<teacher> TeacherTable = dc.GetTable<teacher>();
Teacher teacher = new Teacher();
teacher.Name = Name;
teacher.Family = Family;
teacher.Licence = Licence;
teacher.Image = Bytes;
foreach (Lesson item in Lessons)
{
TeacherLesson tl = new TeacherLesson();
tl.LessonID = item.Id;
Teacher.TeacherLessons.Add(tl);
}
TeacherTable.InsertOnSubmit(Teacher);
TeacherTable.Context.SubmitChanges();
}
</teacher></teacher></lesson>
and this is TeacherLesson table with Foreign-key
CREATE TABLE [dbo].[TeacherLesson] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[teacherID] INT NULL,
[LessonID] INT NULL,
PRIMARY KEY CLUSTERED ([Id] ASC),
CONSTRAINT [FK_TeacherLesson_ToTable] FOREIGN KEY ([teacherID]) REFERENCES [dbo].[Teacher] ([Id])
);