我有下面的方法-
public void SaveNotification()
{
if(ARequest==null) return;
IList<Notification> lstNotification = objDataAccess.GetNotification(_userInfo.UserId);
if(lstNotification?.Count>0)
{
foreach(Notification objNotification in lstNotification)
{
notificationRepository.Insert(objNotification);
}
_dbcontext.SaveChanges();
}
}
关于数据库上下文的保存更改,我得到了-
Operands for operator equal does not match the parameters of method 'op_Equality'
我不知道在这段代码的哪一点上,我正在检查要保存的相等性。
我使用的是.NETCore 2.1.1+OracleEntityframework Core 2.19
这是EFCore上的一个老问题。如果使用==或!=此过程中的操作数使用Equals。试试下面的代码,也可能是在GetNotification
方法的实现中使用==或!=操作数。
public void SaveNotification()
{
if(ARequest.Equals(null)) return;
IList<Notification> lstNotification = objDataAccess.GetNotification(_userInfo.UserId);
if(lstNotification?.Count>0)
{
foreach(Notification objNotification in lstNotification)
{
notificationRepository.Insert(objNotification);
}
_dbcontext.SaveChanges();
}
}
问题参考:https://github.com/dotnet/efcore/issues/11248