我想使用linq lambda表达式删除sql数据库记录。我该怎么做?
这里的“student”是我的数据表,“db”是.edmx文件的对象。
这里的“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;
}