コード例 #1
0
        internal static SqlScriptContent DeserializeSqlScriptContent(JsonElement element)
        {
            string        query                                         = default;
            SqlConnection currentConnection                             = default;
            Optional <SqlScriptMetadata> metadata                       = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("query"))
                {
                    query = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("currentConnection"))
                {
                    currentConnection = SqlConnection.DeserializeSqlConnection(property.Value);
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    metadata = SqlScriptMetadata.DeserializeSqlScriptMetadata(property.Value);
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new SqlScriptContent(query, currentConnection, metadata.Value, additionalProperties));
        }
        internal static SqlScriptContent DeserializeSqlScriptContent(JsonElement element)
        {
            string query = default;
            Optional <SqlConnection>     currentConnection              = default;
            Optional <int>               resultLimit                    = default;
            Optional <SqlScriptMetadata> metadata                       = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("query"))
                {
                    query = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("currentConnection"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    currentConnection = SqlConnection.DeserializeSqlConnection(property.Value);
                    continue;
                }
                if (property.NameEquals("resultLimit"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    resultLimit = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("metadata"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    metadata = SqlScriptMetadata.DeserializeSqlScriptMetadata(property.Value);
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new SqlScriptContent(query, currentConnection.Value, Optional.ToNullable(resultLimit), metadata.Value, additionalProperties));
        }