Data is Null. This method or property cannot be called on Null values

后端 未结 7 1038
伪装坚强ぢ
伪装坚强ぢ 2021-02-06 20:07

I\'m working on an application where one can get information on movies from a database as well as add, update and delete the movies. In the database I have three tables (Movie,

7条回答
  •  后悔当初
    2021-02-06 20:57

    BookingQuantity - column having null value in DB. but actual DB BookingQuantity not null column. Some rare case it happens to enter. In that case below code throw error the same error(Data is Null. This method or property cannot be called on Null values ).

    totalBookingQuantity += item.InspPoTransactions.Where(x => x.PoId == inspectionPODetail.PoId && x.ProductId == inspectionPODetail.ProductId).Sum(x => Convert.ToInt32(x.BookingQuantity));

提交回复
热议问题