Skip to content

Commit

Permalink
Add property FbCommand.NamedParameters (#1161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Trubač committed Mar 2, 2024
1 parent cf461dc commit 4e0e28f
Show file tree
Hide file tree
Showing 2 changed files with 26 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
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 by <see cref="NamedParametersParser"/> during command prepare.
/// </summary>
[Category("Data")]
[DefaultValue(new string[] { })]
public IReadOnlyList<string> NamedParameters
{
get { return _namedParameters; }
}

#endregion

#region Protected DbCommand Properties
Expand Down

0 comments on commit 4e0e28f

Please sign in to comment.