C#C
C#3y ago
SWEETPONY

how to join will null?

I have this logic:
private async Task OnChannelsGet(
    IDeliveryHandlerContext context,
    MessagingSubjectsChannelsGetArguments arguments)
{
    var channelsGetResponse = await _messagingChannelsClient
        .ChannelsGet(new(arguments.Names))
        .Unwrap();

    var channelSettingsResponse = await _systemServiceClient
        .DataGet(new(arguments.Names))
        .Unwrap();

    var channelSettingsSchema = await ChannelSettingsSchemaCreate();

    var result = channelsGetResponse.Items
        .Join( channelSettingsResponse.Items,
            mutationDto => mutationDto.Name,
            channelSettingsDto => channelSettingsDto.Key,
            (channelDto, channelSettingsDto) =>
                new MessagingSubjectsChannelGetDto
                {
                    Name = channelDto.Name,
                    Title = channelDto.Title.GetValue(context.Culture),
                    Description = channelDto.Description.GetValue(context.Culture),
                    Configuration = channelDto.Configuration,
                    Settings = channelSettingsDto.Data.FromJson<ChannelSettingsDto>(),
                    SettingsSchema = channelSettingsSchema
                } )
        .ToList();

    await context.TryRespondOk(new MessagingSubjectsChannelsGetResponse(result));
}


channelSettingsResponse can be null or we couldn't join by keys and now result will be null
but I don't need it. If something bad with channelSettingsResponse, I'd like to return
new MessagingSubjectsChannelGetDto
{
       Name = channelDto.Name,
       Title = channelDto.Title.GetValue(context.Culture),
       Description = channelDto.Description.GetValue(context.Culture),
       Configuration = channelDto.Configuration,
       Settings = null,
       SettingsSchema = channelSettingsSchema
} )
Was this page helpful?