'Constructing or initializing instances of the type with the expression (<expression> == null) is not supported

I am accessing OData API using ODataConnectedService.

When I use this code;

UpcomingJobsItems = context.EventStaffRequired
  .Select(c => new UpcomingJob
  {
     EventType = c.Event.EventType == null ? "" : c.Event.EventType.Type,
  });

I am getting below error;

System.NotSupportedException: 'Constructing or initializing instances of the type UpcomingJob with the expression (c.Event.EventType == null) is not supported.'

If I don't check for null I get error on null values. How can I handle null values in this case?

Thanks

Regards



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source