【发布时间】:2015-05-21 08:29:57
【问题描述】:
我想使用 linq lambda 表达式删除 sql 数据库的记录。我该怎么办?
这里 'student' 是我的表,'db' 是 .edmx 文件的对象
public bool DeleteRecord(int caurseID)
{
studentEntities db = new studentEntities();
int count = db.student.Where(s => s.caurse_id == caurseID).Count();
if (count != 0)
{
//string subQuery = "delete from student where caurse_id=" + caurseID;
//SqlCommand subCmd = new SqlCommand(subQuery, conn);
//subCmd.ExecuteNonQuery();
db.student. : For Delete, what will be goes here???
}
return true;
}
【问题讨论】:
标签: c# asp.net linq entity-framework lambda