Commit bb5a16ce authored by Marc Gravell's avatar Marc Gravell

SO30435185; make it clearer if the caller is passing an array (etc) when they...

SO30435185; make it clearer if the caller is passing an array (etc) when they should be passing a single object
parent 84027051
......@@ -2116,6 +2116,10 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
CacheInfo info;
if (!TryGetQueryCache(identity, out info))
{
if(GetMultiExec(exampleParameters) != null)
{
throw new InvalidOperationException("An enumerable sequence of parameters (arrays, lists, etc) is not allowed in this context");
}
info = new CacheInfo();
if (identity.parametersType != null)
{
......
......@@ -4573,5 +4573,42 @@ public void SO30156367_DynamicParamsWithoutExec()
var value = dbParams.Get<int>("Field1");
value.IsEqualTo(1);
}
public void SO30435185_InvalidTypeOwner()
{
try {
string sql = @" INSERT INTO #XXX
(XXXId, AnotherId, ThirdId, Value, Comment)
VALUES
(@XXXId, @AnotherId, @ThirdId, @Value, @Comment); select @@rowcount as [Foo]";
var command = new
{
MyModels = new[]
{
new {XXXId = 1, AnotherId = 2, ThirdId = 3, Value = "abc", Comment = "def" }
}
};
var parameters = command
.MyModels
.Select(model => new
{
XXXId = model.XXXId,
AnotherId = model.AnotherId,
ThirdId = model.ThirdId,
Value = model.Value,
Comment = model.Comment
})
.ToArray();
var rowcount = (int)connection.Query(sql, parameters).Single().Foo;
rowcount.IsEqualTo(1);
Assert.Fail();
} catch(InvalidOperationException ex)
{
ex.Message.IsEqualTo("An enumerable sequence of parameters (arrays, lists, etc) is not allowed in this context");
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment