Commit 06abcbdf authored by mgravell's avatar mgravell

oops, fix crappy perf; also take out all @ code from parameters'

parent 0a28a98e
This diff is collapsed.
...@@ -72,11 +72,17 @@ public void PassInIntArray() ...@@ -72,11 +72,17 @@ public void PassInIntArray()
.IsSequenceEqualTo(new[] { 1, 2, 3 }); .IsSequenceEqualTo(new[] { 1, 2, 3 });
} }
public void PassInEmptyIntArray()
{
connection.Query<int>("select * from (select 1 as Id union all select 2 union all select 3) as X where Id in @Ids", new { Ids = new int[0] })
.IsSequenceEqualTo(new int[0]);
}
public void TestReadMultipleIntegersWithSplitOnAny() public void TestReadMultipleIntegersWithSplitOnAny()
{ {
connection.Query<int,int,int,Tuple<int,int,int>>( connection.Query<int, int, int, Tuple<int, int, int>>(
"select 1,2,3 union all select 4,5,6", Tuple.Create, splitOn: "*") "select 1,2,3 union all select 4,5,6", Tuple.Create, splitOn: "*")
.IsSequenceEqualTo(new[] {Tuple.Create(1,2,3), Tuple.Create(4,5,6)}); .IsSequenceEqualTo(new[] { Tuple.Create(1, 2, 3), Tuple.Create(4, 5, 6) });
} }
public void TestDoubleParam() public void TestDoubleParam()
...@@ -131,7 +137,7 @@ public class Dog ...@@ -131,7 +137,7 @@ public class Dog
public void TestExtraFields() public void TestExtraFields()
{ {
var guid = Guid.NewGuid(); var guid = Guid.NewGuid();
var dog = connection.Query<Dog>("select '' as Extra, 1 as Age, 0.1 as Name1 , Id = @id", new { Id = guid}); var dog = connection.Query<Dog>("select '' as Extra, 1 as Age, 0.1 as Name1 , Id = @id", new { Id = guid });
dog.Count() dog.Count()
.IsEqualTo(1); .IsEqualTo(1);
...@@ -183,8 +189,8 @@ public void TestExpando() ...@@ -183,8 +189,8 @@ public void TestExpando()
public void TestStringList() public void TestStringList()
{ {
connection.Query<string>("select * from (select 'a' as x union all select 'b' union all select 'c') as T where x in @strings", new {strings = new[] {"a","b","c"}}) connection.Query<string>("select * from (select 'a' as x union all select 'b' union all select 'c') as T where x in @strings", new { strings = new[] { "a", "b", "c" } })
.IsSequenceEqualTo(new[] {"a","b","c"}); .IsSequenceEqualTo(new[] { "a", "b", "c" });
connection.Query<string>("select * from (select 'a' as x union all select 'b' union all select 'c') as T where x in @strings", new { strings = new string[0] }) connection.Query<string>("select * from (select 'a' as x union all select 'b' union all select 'c') as T where x in @strings", new { strings = new string[0] })
.IsSequenceEqualTo(new string[0]); .IsSequenceEqualTo(new string[0]);
...@@ -199,12 +205,12 @@ public void TestExecuteCommand() ...@@ -199,12 +205,12 @@ public void TestExecuteCommand()
insert #t insert #t
select @a a union all select @b select @a a union all select @b
set nocount on set nocount on
drop table #t", new {a=1, b=2 }).IsEqualTo(2); drop table #t", new { a = 1, b = 2 }).IsEqualTo(2);
} }
public void TestExecuteCommandWithHybridParameters() public void TestExecuteCommandWithHybridParameters()
{ {
var p = new DynamicParameters(new { a = 1, b = 2 }); var p = new DynamicParameters(new { a = 1, b = 2 });
p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("c", dbType: DbType.Int32, direction: ParameterDirection.Output);
connection.Execute(@"set @c = @a + @b", p); connection.Execute(@"set @c = @a + @b", p);
p.Get<int>("@c").IsEqualTo(3); p.Get<int>("@c").IsEqualTo(3);
} }
...@@ -591,21 +597,21 @@ public void TestEnumStrings() ...@@ -591,21 +597,21 @@ public void TestEnumStrings()
public void TestSupportForParamDictionary() public void TestSupportForParamDictionary()
{ {
var p = new DynamicParameters(); var p = new DynamicParameters();
p.Add("@name", "bob"); p.Add("name", "bob");
p.Add("@age", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("age", dbType: DbType.Int32, direction: ParameterDirection.Output);
connection.Query<string>("set @age = 11 select @name", p).First().IsEqualTo("bob"); connection.Query<string>("set @age = 11 select @name", p).First().IsEqualTo("bob");
p.Get<int>("@age").IsEqualTo(11); p.Get<int>("age").IsEqualTo(11);
} }
public void TestProcSupport() public void TestProcSupport()
{ {
var p = new DynamicParameters(); var p = new DynamicParameters();
p.Add("@a", 11); p.Add("a", 11);
p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("b", dbType: DbType.Int32, direction: ParameterDirection.Output);
p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue); p.Add("c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
connection.Execute(@"create proc #TestProc connection.Execute(@"create proc #TestProc
@a int, @a int,
...@@ -618,8 +624,8 @@ select 1111 ...@@ -618,8 +624,8 @@ select 1111
end"); end");
connection.Query<int>("#TestProc", p, commandType: CommandType.StoredProcedure).First().IsEqualTo(1111); connection.Query<int>("#TestProc", p, commandType: CommandType.StoredProcedure).First().IsEqualTo(1111);
p.Get<int>("@c").IsEqualTo(11); p.Get<int>("c").IsEqualTo(11);
p.Get<int>("@b").IsEqualTo(999); p.Get<int>("b").IsEqualTo(999);
} }
...@@ -670,8 +676,8 @@ public void TestFlexibleMultiMapping() ...@@ -670,8 +676,8 @@ public void TestFlexibleMultiMapping()
2 as AddressId, 'abc street' as Name, 1 as PersonId, 2 as AddressId, 'abc street' as Name, 1 as PersonId,
3 as Id, 'fred' as Name 3 as Id, 'fred' as Name
"; ";
var personWithAddress = connection.Query<Person, Address, Extra, Tuple<Person, Address,Extra>> var personWithAddress = connection.Query<Person, Address, Extra, Tuple<Person, Address, Extra>>
(sql, (p,a,e) => Tuple.Create(p, a, e), splitOn: "AddressId,Id").First(); (sql, (p, a, e) => Tuple.Create(p, a, e), splitOn: "AddressId,Id").First();
personWithAddress.Item1.PersonId.IsEqualTo(1); personWithAddress.Item1.PersonId.IsEqualTo(1);
personWithAddress.Item1.Name.IsEqualTo("bob"); personWithAddress.Item1.Name.IsEqualTo("bob");
...@@ -736,7 +742,7 @@ public void AddParameters(IDbCommand command) ...@@ -736,7 +742,7 @@ public void AddParameters(IDbCommand command)
} }
// Add the table parameter. // Add the table parameter.
var p = sqlCommand.Parameters.Add("@ints", SqlDbType.Structured); var p = sqlCommand.Parameters.Add("ints", SqlDbType.Structured);
p.Direction = ParameterDirection.Input; p.Direction = ParameterDirection.Input;
p.TypeName = "int_list_type"; p.TypeName = "int_list_type";
p.Value = number_list; p.Value = number_list;
...@@ -796,7 +802,7 @@ public void ParentChildIdentityAssociations() ...@@ -796,7 +802,7 @@ public void ParentChildIdentityAssociations()
return found; return found;
}).Distinct().ToDictionary(p => p.Id); }).Distinct().ToDictionary(p => p.Id);
parents.Count().IsEqualTo(3); parents.Count().IsEqualTo(3);
parents[1].Children.Select(c => c.Id).SequenceEqual(new[] { 1,2,4}).IsTrue(); parents[1].Children.Select(c => c.Id).SequenceEqual(new[] { 1, 2, 4 }).IsTrue();
parents[2].Children.Select(c => c.Id).SequenceEqual(new[] { 3 }).IsTrue(); parents[2].Children.Select(c => c.Id).SequenceEqual(new[] { 3 }).IsTrue();
parents[3].Children.Select(c => c.Id).SequenceEqual(new[] { 5 }).IsTrue(); parents[3].Children.Select(c => c.Id).SequenceEqual(new[] { 5 }).IsTrue();
} }
......
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