【发布时间】:2015-10-10 20:47:14
【问题描述】:
我想更新 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 是正确的解决方案。
建议!
【问题讨论】:
-
这可能对你有帮助:codeproject.com/Articles/358445/…
标签: c# sql-server asp.net-mvc entity-framework linq-to-sql