sql server - linq to sql , can not solve big sql statement into linq -
i trying hard cannot reach result. new linq. should proper linq query sql query. please me out of this.
update teacher set remainingcredit = remainingcredit- course.credit courseassignteacher join course on courseassignteacher.courseid = course.id join teacher on courseassignteacher.teacherid = teacher.id courseassignteacher.id = 1
write query selects want update, use foreach
loop , context.submitchanges
:
using (dbdatacontext db = new dbdatacontext()) { var toupdate = cat in db.courseassignteacher join c in db.course on cat.courseid equals c.id join t in db.teacher on cat.teacherid equals t.id cat.id = 1 select new { teacher = t, course = c, courseassignteacher = cat }; foreach (var x in toupdate) { x.teacher.remainingcredit = x.teacher.remainingcredit - x.course.credit; } db.submitchanges(); }
Comments
Post a Comment