EF增删改查
参考:
https://www.cnblogs.com/zry2510/p/6209118.html
EF查询表的某个字段的最大值
var a=db.表名.Select(s=>s.列名).Max();
EF查询表是否表中已存在某个值
var a=db.表名.Any(s=>s.列名==传入的值);
if(a){ 已存在 }
或者
from x in a where !b.Any(y=>y.id==x.id) select x;
EF 查询所有字段
var query=db.表名.Where(r=> r.Id==Id).Select(p=>p).ToList();
EF 查询部分字段
var query=db.表名.Where(r=> r.Id==Id).Select(g=>new{d.Id, d.想要的字段}).ToList();
EF修改部分字段
参考:
https://www.cnblogs.com/jhxk/articles/9719606.html
https://www.cnblogs.com/zxsn/p/12658355.html
EF 链表查询
参考:
https://www.cnblogs.com/tinya/p/4623503.html
https://www.cnblogs.com/renyan52099/p/14781372.html
http://www.voidcn.com/article/p-rqfusmvr-bqh.html
查看EF生成的SQL语句
参考:
https://www.cnblogs.com/cxxtreasure/p/13382726.html
EF执行Sql查询
参考:
https://www.cnblogs.com/cxxtreasure/p/13382695.html
EF + Lambda分页
参考:
https://blog.csdn.net/xoofly/article/details/84317408
EF + LINQ查询前N条记录
参考:
https://blog.csdn.net/ptyzhu/article/details/7893563
linq GroupBy 多字段分组
参考:
https://www.cnblogs.com/tianyang1027/p/13931811.html
C#EF保存多个记录
using(var db = context) { var dataToUpdate = db.Employees.ToList(); var department= "IT"; dataToUpdate.ForEach(x=>{ x.department = department; }); db.SaveChanges(); }