https://blog.csdn.net/yangyangafan/article/details/77602133
EntityFramework enigmatic convenient operation of the database also need to write the database, but the premise is very simple CRUD, when faced with conditions somewhat careful inquiry would not be able to check the ~, finally returned to write sql statement -
recorded in one EntityFramework write sql statement
For example, a query table in the student's name is Xiao Ming came in the first student - do not modify the sql statement and Age
student stu=db.student.where(o=>o.name="小明").FirstOrDefault();
{
stu.sex=15;
}
db.saveChange();
Modify the use of the sql statement
student stu=db.DataBase.sqlQuery<student>(select * from student where name="小明").FirstOrDefault();
{stu.sex=15;}
db.Entry<student>(stu).State = System.Data.Entity.EntityState.Modified;
db.saveChanges();