blob: a5f38d792c86d4bd6438f5b468cc505e0cdfe974 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace Apache.Ignite.Sql;
using System;
using System.Data;
using System.Data.Common;
using System.Diagnostics.CodeAnalysis;
using Internal.Common;
/// <summary>
/// Ignite database parameter.
/// </summary>
public sealed class IgniteDbParameter : DbParameter
{
/// <summary>
/// Initializes a new instance of the <see cref="IgniteDbParameter"/> class.
/// </summary>
public IgniteDbParameter()
{
// No-op.
}
/// <inheritdoc />
public override DbType DbType { get; set; } = DbType.String;
/// <summary>
/// Gets or sets the direction of the parameter. Only <see cref="ParameterDirection.Input" /> is supported.
/// </summary>
/// <value>The direction of the parameter.</value>
public override ParameterDirection Direction
{
get => ParameterDirection.Input;
set
{
if (value != ParameterDirection.Input)
{
throw new ArgumentException($"Only ParameterDirection.Input is supported: {value}", nameof(value));
}
}
}
/// <inheritdoc />
public override bool IsNullable { get; set; }
/// <inheritdoc />
[AllowNull]
public override string ParameterName { get; set; } = string.Empty;
/// <inheritdoc />
[AllowNull]
public override string SourceColumn { get; set; } = string.Empty;
/// <inheritdoc />
public override object? Value { get; set; }
/// <inheritdoc />
public override bool SourceColumnNullMapping { get; set; }
/// <inheritdoc />
public override int Size { get; set; }
/// <inheritdoc />
public override void ResetDbType() => DbType = DbType.String;
/// <inheritdoc/>
public override string ToString() =>
new IgniteToStringBuilder(GetType())
.Append(Value) // Only value is important for an Ignite parameter.
.Build();
}