基本上我从表中检索了记录并想更新一列。
var query = cdrContext.tabless.Where(c => c.FacilityID == facilityID && c.FilePath != null && c.TimeStationOffHook < oldDate)
.OrderBy(c => c.TimeStationOffHook)
.Skip(size)
.Take(pageSize)
.Select(c => new { c.FilePath, c.FileName })
.ToList();
所以这个查询只有两个字段:FilePath 和 FileName,那么接下来我要赋值 FilePath = null;
foreach (var y in query)
{
y.FilePath = null;
}
cdrContext.SaveChanges();
然后我得到一个错误:
Property or indexer 'AnonymousType#1.FilePath' cannot be assigned to -- it is read only