当前位置:网站首页>[bug] the element in C iqueryable cannot change its value

[bug] the element in C iqueryable cannot change its value

2022-06-23 23:52:00 I left my life to work

Code

The code has been changed , It's just an excerpt , But it's the same

var sysPersonnels=SysPersonnelRepository.FindAsIQueryable(f => f.IsDeleted == 1 && f.SyncWithDhDeletedTime == null).IgnoreQueryFilters();

sysPersonnels= personel_Erp.Where(f => f.PersonnelName.Contains(" test ")).Take(2);

 foreach (SysPersonnel personnel in sysPersonnels)
{
    
    personnel.SyncWithDhDeletedTime = DateTime.Now;
}
//foreach  End sysPersonnels Inside SysPersonnel  Of SyncWithDhDeletedTime  Still no value   The following updates will not work 
SysPersonnelRepository.UpdateRange(sysPersonnels, x => new {
    
    x.SyncWithDhDeletedTime
}); 

reason

Change to List After that

  var personel_Erp=SysPersonnelRepository.FindAsIQueryable(f => f.IsDeleted == 1 && f.SyncWithDhDeletedTime == null).IgnoreQueryFilters().ToList();
 personel_Erp= personel_Erp.Where(f => f.PersonnelName.Contains(" test ")).Take(2).ToList();

I don't know why , Also look at the big god pointing a thing or two

There are similar problems on the Internet that I don't quite understand : Why can't it be changed IQueryable The attributes of the elements inside ?

原网站

版权声明
本文为[I left my life to work]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/174/202206232109480864.html