Skip to content

Commit

Permalink
Merge pull request #53 from teamyudin/master
Browse files Browse the repository at this point in the history
Multi-Mapping issue with SplitOn
  • Loading branch information
SamSaffron committed Oct 7, 2012
2 parents 92d1fbe + bce5e13 commit 399db17
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dapper/SqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ private static Func<IDataReader, object>[] GenerateDeserializers(Type[] types, s

Func<Type, int> nextSplit = type =>
{
var currentSplit = splits[splitIndex];
var currentSplit = splits[splitIndex].Trim();
if (splits.Length > splitIndex + 1)
{
splitIndex++;
Expand Down
19 changes: 19 additions & 0 deletions Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,25 @@ public void TestFlexibleMultiMapping()

}

public void TestMultiMappingWithSplitOnSpaceBetweenCommas()
{
var sql = @"select
1 as PersonId, 'bob' as Name,
2 as AddressId, 'abc street' as Name, 1 as PersonId,
3 as Id, 'fred' as Name
";
var personWithAddress = connection.Query<Person, Address, Extra, Tuple<Person, Address, Extra>>
(sql, (p, a, e) => Tuple.Create(p, a, e), splitOn: "AddressId, Id").First();

personWithAddress.Item1.PersonId.IsEqualTo(1);
personWithAddress.Item1.Name.IsEqualTo("bob");
personWithAddress.Item2.AddressId.IsEqualTo(2);
personWithAddress.Item2.Name.IsEqualTo("abc street");
personWithAddress.Item2.PersonId.IsEqualTo(1);
personWithAddress.Item3.Id.IsEqualTo(3);
personWithAddress.Item3.Name.IsEqualTo("fred");

}

public void TestFastExpandoSupportsIDictionary()
{
Expand Down

0 comments on commit 399db17

Please sign in to comment.