/// <summary>
        /// Writes query field instance to the specified writer.
        /// </summary>
        private static void WriteQueryField(BinaryWriter writer, QueryField field, ClientFeatures features)
        {
            Debug.Assert(writer != null);

            writer.WriteString(field.Name);
            writer.WriteString(field.FieldTypeName);
            writer.WriteBoolean(field.IsKeyField);
            writer.WriteBoolean(field.NotNull);
            writer.WriteObject(field.DefaultValue);

            if (features.HasQueryFieldPrecisionAndScale())
            {
                writer.WriteInt(field.Precision);
                writer.WriteInt(field.Scale);
            }
        }
        /// <summary>
        /// Read query field.
        /// </summary>
        private static QueryField ReadQueryField(BinaryReader reader, ClientFeatures features)
        {
            Debug.Assert(reader != null);

            var value = new QueryField
            {
                Name          = reader.ReadString(),
                FieldTypeName = reader.ReadString(),
                IsKeyField    = reader.ReadBoolean(),
                NotNull       = reader.ReadBoolean(),
                DefaultValue  = reader.ReadObject <object>()
            };

            if (features.HasQueryFieldPrecisionAndScale())
            {
                value.Precision = reader.ReadInt();
                value.Scale     = reader.ReadInt();
            }

            return(value);
        }