我有一个 tolist 方法,可以在数据库内部进行更改,但我想计算我的Where 子句为 true 的次数。Tolist 有效,我如何添加计数..
// the count to see how many times getid== x.RegistrationID
List<Article> getprofile = (from x in db.Articles where getid == x.RegistrationID select x).ToList();
foreach (var items in getprofile)
{
items.articlecount = items.articlecount + 1;
db.Entry(items).State = EntityState.Modified;
db.SaveChanges();
}