Skip to content

Commit

Permalink
Add property FbCommand.NamedParameters (#1161) (#1168)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Trubač <[email protected]>
  • Loading branch information
dant02 and Daniel Trubač authored Apr 14, 2024
1 parent b1d6fa2 commit 55eb350
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/FirebirdSql.Data.FirebirdClient.Tests/FbCommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,22 @@ public async Task NamedParametersReuseTest()
}
}

[Test]
public async Task NamedParametersPublicAccessor()
{
await using (var command = new FbCommand("select * from test where int_field >= @x1 and int_field <= @x2", Connection))
{
Assert.IsNotNull(command.NamedParameters, "Unexpected null reference.");
Assert.IsTrue(command.NamedParameters.Count == 0, "Expected count 0 of named parameters before command prepare.");

await command.PrepareAsync();

Assert.IsTrue(command.NamedParameters.Count == 2, "Expected count 2 of named parameters after command prepare.");
Assert.AreEqual(command.NamedParameters[0], "@x1");
Assert.AreEqual(command.NamedParameters[1], "@x2");
}
}

[Test]
public async Task ExecuteStoredProcTest()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,16 @@ public int BatchBufferSize
}
}

/// <summary>
/// Gets collection of parameters parsed from the query text during command prepare.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IReadOnlyList<string> NamedParameters
{
get { return _namedParameters; }
}

#endregion

#region Internal Properties
Expand Down
10 changes: 10 additions & 0 deletions src/FirebirdSql.Data.FirebirdClient/FirebirdClient/FbCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,16 @@ public int FetchSize
}
}

/// <summary>
/// Gets collection of parameters parsed from the query text during command prepare.
/// </summary>
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IReadOnlyList<string> NamedParameters
{
get { return _namedParameters; }
}

#endregion

#region Protected DbCommand Properties
Expand Down

0 comments on commit 55eb350

Please sign in to comment.