© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
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));
}
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
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
} )
new MessagingSubjectsChannelGetDto
{
       Name = channelDto.Name,
       Title = channelDto.Title.GetValue(context.Culture),
       Description = channelDto.Description.GetValue(context.Culture),
       Configuration = channelDto.Configuration,
       Settings = null,
       SettingsSchema = channelSettingsSchema
} )
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

NullReferenceException but checking for Null?
C#CC# / help
2y ago
Converting null literal or possible null value to non-nullable type.
C#CC# / help
2y ago
❔ Converting null iteral or possible null value to non-nullable type
C#CC# / help
3y ago