score:0

Accepted answer

I am not sure why you are getting the error but here is a suggestion:

Order order;
if(order == null)
{
    if (reg.OrderId != null)
    {
        order = db.Orders.Where(o => o.OrderId == reg.OrderId).FirstOrDefault();
    }
    else
    {
        order = new Order();
    }
}

Related Articles