Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/Data/Client/TDengineCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Data;
using System.Data.Common;
using System.Collections.Generic;

using TDengine.Driver;

namespace TDengine.Data.Client
Expand All @@ -24,7 +23,6 @@ public TDengineCommand()
public TDengineCommand(TDengineConnection connection)
{
_connection = connection;
_stmt = connection.client.StmtInit();
}

public override void Cancel()
Expand Down Expand Up @@ -127,7 +125,9 @@ public override CommandType CommandType
protected override DbConnection DbConnection
{
get => _connection;
set => _connection = value as TDengineConnection ?? throw new ArgumentException($"The specified connection is not of type {nameof(TDengineConnection)}.");
set => _connection = value as TDengineConnection ??
throw new ArgumentException(
$"The specified connection is not of type {nameof(TDengineConnection)}.");
}

protected override DbParameterCollection DbParameterCollection => _parameters.Value;
Expand All @@ -151,22 +151,24 @@ private IRows Query()

private IRows Statement()
{
if(_stmt == null && _connection != null)
if (!_parameters.IsValueCreated || _parameters.Value.Count == 0)
{
return Query();
}

if (_stmt == null && _connection != null)
{
_stmt = _connection.client.StmtInit();
}

if (_stmt == null) throw new InvalidOperationException("Statement is null");

if (!_isPrepared)
{
_isPrepared = true;
_stmt.Prepare(_commandText);
}

if (!_parameters.IsValueCreated || _parameters.Value.Count == 0)
{
return Query();
}

var isInsert = _stmt.IsInsert();

var pms = _parameters.Value;
Expand Down