提交 603b2125 编写于 作者: M Marc Gravell

Added tests to complement documentation of pseudo-positional parameters

上级 e15cb95d
......@@ -3315,6 +3315,38 @@ public void Issue569_SO38527197_PseudoPositionalParameters_In()
}
}
[Fact]
public void PseudoPositional_CanUseVariable()
{
using (var connection = ConnectViaOledb())
{
int id = 42;
var row = connection.QuerySingle("declare @id int = ?id?; select @id as [A], @id as [B];", new { id });
int a = (int)row.A;
int b = (int)row.B;
a.IsEqualTo(42);
b.IsEqualTo(42);
}
}
[Fact]
public void PseudoPositional_CannotUseParameterMultipleTimes()
{
using (var connection = ConnectViaOledb())
{
try
{
int id = 42;
var row = connection.QuerySingle("select ?id? as [A], ?id? as [B];", new { id });
Assert.Fail();
}
catch (InvalidOperationException ex) when (ex.Message == "When passing parameters by position, each parameter can only be referenced once")
{
// that's a win
}
}
}
[Fact]
public void PseudoPositionalParameters_ExecSingle()
{
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册