我想更新LINQ to SQL中的一列。我的查询是这样的: -更新LINQ to SQL的操作
private void UpdateCourse()
{
OperationDataContext OdContext = new OperationDataContext();
//Get Single course which need to update
COURSE objCourse = OdContext.COURSEs.Single(course => course.course_name == "B.Tech");
//Field which will be update
objCourse.course_desc = "Bachelor of Technology";
// executes the appropriate commands to implement the changes to the database
OdContext.SubmitChanges();
}
我的问题是第一次从符合条件的课程记录它比它更新它。这是正确的方法?或者SP是正确的解决方案。
建议!
这可能会帮助你:http://www.codeproject.com/Articles/358445/Most-efficient-way-to-update-with-LINQ-to-SQL –