询价订单型号
public class InquiryOrder
{
[Key]
public int InquiryOrderId { get; set; }
public string InquiryOrderName { get; set; }
[ForeignKey("ProductType")]
public int? ProductTypeId { get; set; }
public virtual ProductType ProductType { get; set; }
}
查询订单控制器
var displayedInquiryOrders = filteredInquiryOrders.Skip(iDisplayStart).Take(iDisplayLength);
var result = from c in displayedInquiryOrders .AsEnumerable()
select new[] {
Convert.ToString(c.InquiryOrderId),
c.InquiryOrderName,
c.ProductType.ProductTypeName,
};
如果表ProductTypeId
中有空值,我会从数组中InquiryOrder
获取此错误。如何调整此数组以使其接受 int 的空值。谢谢!Object reference not set to an instance of an object
c.ProductType.ProductTypeName