C# accessing properties belonging to instance which is of object? (i.e. Nullable) type

C# accessing properties belonging to instance which is of object? (i.e. Nullable) type


0

Here is info about our technical development environment :

• .NET 6

• C# 10

• GraphQL 7.1.1

• GraphQL.Client 5.1.0

• GraphQL.Client.Serializer.Newtonsoft 5.1.0

GraphQLRequest request = new GraphQLRequest
        {
            Query = @"
            mutation FaxReceiverInfo(
                        $_DateCreated: datetime,
                        $_FaxNumber: String,
                        $_FaxRecord: uniqueidentifier,
                        $_Reason: String
            )
            {
            insert_vw_EmailDeliveryRecordDetail_one
              ( 
                    object: {
                             DateCreated: $_DateCreated,
                             FaxNumber: $_FaxNumber,
                             FaxRecord: $_FaxRecord,
                             Reason: $_Reason
            }
            ) 
            {
                DateCreated
                FaxNumber
                FaxRecord
                Reason                  }
            }",
            OperationName = "FaxReceiverInfo",
            Variables = new
            {
                _DateCreated = DateTimeOffset.FromUnixTimeMilliseconds(metaData.TimeStamp).DateTime.ToString("dd-MMM-yyyy
 hh:mm:ss tt"),

                _FaxNumber = metaData.FaxNumber,
                _FaxRecord = metaData.FaxRecord,
                _Reason = metaData.Reason
            }
        };

Within the GraphQL 7.1.1 , the Variables of of type object?

namespace GraphQL;

/// <summary>
/// A GraphQL request
/// </summary>

 public class  GraphQLRequest : Dictionary<string, object>, IEquatable<GraphQLRequest?> {
      public const string VARIABLES_KEY = "variables";
      ……….Blah Blah Blah More Code……..
      /// <summary>
      /// Represents the request variables
      /// </summary>
      public object? Variables
      {
            get => TryGetValue(VARIABLES_KEY, out object value) ? value : null;
            set => this[VARIABLES_KEY] = value;
      }
        ……….Blah Blah Blah More Code……..
  }

In the client code that uses the aforementioned request of type GraphQLRequest, I’m trying to access the properties within the request.Variables member variable:

request.Variables……blahblah _DateCreated Blah blah

request.Variables……blahblah _FaxRecord Blah blah

Essentially, could someone please post back code that will properly access the properties within the request.Variables( which is of object? type) member variable?

Share
Improve this question


Load 6 more related questions


Show fewer related questions

0

Reset to default



Leave a Reply

Your email address will not be published. Required fields are marked *