可以试试 Entity Framework Core Plus
// using Z.EntityFramework.Plus; // Don't forget to include this.
// DELETE all users inactive for 2 years
var date = DateTime.Now.AddYears(-2);
ctx.Users.Where(x => x.LastLoginDate < date)
.Delete();
// DELETE using a BatchSize
var date = DateTime.Now.AddYears(-2);
ctx.Users.Where(x => x.LastLoginDate < date)
.Delete(x => x.BatchSize = 1000);
可以 解决了俺的问题
1 排除字段:我记得EF 查询时时有.ignore的方法的
2 加载部分字段:找了一下
using (var context = new EntityContext())
{
var result = from s in context.Users
orderby s.ID
select new {s.name,s.years};
};
https://ithelp.ithome.com.tw/questions/10192142
dbEntities db = new dbEntities();
var list = db.news.Select(c => new { c.title, c.times }).ToList();/