Entity framework 運用過程中,條件查詢時會出現 MVC c# 沒有為類型“System.Nullable`1[System.Int32]”和“System.Int32”定義二進制運算符 Equal。
處理方法:int類型進行連接是, 非空和非零的前提下才進行Equal,所以嘗試轉換成int成功就可以處理掉這個異常。
int UserId ;
if (int.TryParse(Request["UserId"], out UserId))
{
where.Equal("UserId", UserId);
}