我正在使用 LINQ to SQL,我有一个名为“tblCourse”的表,我想根据某些条件从该表中选择一些行,然后将这些选定的行作为新记录插入到同一个表中。任何机构都可以提出一些帖子、链接或方向吗?
public IQueryable<tblCourseNeededHours> CloneAllCourseNeededHoursInDepartmentInSemester(int departmentId, string semester)
{
return from allCourses in _db.tblCourseNeededHours orderby allCourses.tblCourse.CourseName
where allCourses.tblCourse.tblInstitute.DepartmentID == departmentId && allCourses.Semester
== semester select allCourses;
var thisTable = from t in _db.tblCourseNeededHours where
t.tblCourse.tblInstitute.DepartmentID == departmentId && t.Semester == semester
//select everything except ID
select _db.tblCourseNeededHours { Semester = ?, NeedHoursPerWeek = ?, AssignToInstitute=?
(I want it null for new record), Freezed=? (I want it null for new record)
};
_db.tblCourseNeededHours.InsertAllOnsubmit(thisTable);
_db.SubmitChanges();
现在当我使用
select _db.tblCourseNeededHours { Semester = ?, NeedHoursPerWeek = ?, AssignToInstitute=? (I want it null), Freezed=? (I want it null)
};
? 提到“我应该把什么放在这里,我在这里有错误,也在这条线上
_db.tblCourseNeededHours.InsertAllOnsubmit(thisTable);