Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
be18f157
Commit
be18f157
authored
Jul 19, 2011
by
Sam Saffron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
multi mapper for grid has a serious bug ...
parent
b27a2e64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
SqlMapper.cs
Dapper/SqlMapper.cs
+1
-1
Tests.cs
Tests/Tests.cs
+48
-0
No files found.
Dapper/SqlMapper.cs
View file @
be18f157
...
...
@@ -1390,7 +1390,7 @@ public IEnumerable<T> Read<T>()
},
gridIndex
);
try
{
foreach
(
var
r
in
SqlMapper
.
MultiMapImpl
<
TFirst
,
TSecond
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
null
,
null
,
func
,
null
,
null
,
splitOn
,
null
,
null
,
reader
,
identity
))
foreach
(
var
r
in
SqlMapper
.
MultiMapImpl
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TReturn
>(
null
,
null
,
func
,
null
,
null
,
splitOn
,
null
,
null
,
reader
,
identity
))
{
yield
return
r
;
}
...
...
Tests/Tests.cs
View file @
be18f157
...
...
@@ -341,6 +341,7 @@ class Post
public
int
Id
{
get
;
set
;
}
public
User
Owner
{
get
;
set
;
}
public
string
Content
{
get
;
set
;
}
public
Comment
Comment
{
get
;
set
;
}
}
public
void
TestMultiMap
()
{
...
...
@@ -978,5 +979,52 @@ public void TestInvalidSplitCausesNiceError()
// expecting an app exception due to multi mapping being bodged
}
}
class
Comment
{
public
int
Id
{
get
;
set
;
}
public
string
CommentData
{
get
;
set
;
}
}
public
void
TestMultiMapThreeTypesWithGridReader
()
{
var
createSql
=
@"
create table #Users (Id int, Name varchar(20))
create table #Posts (Id int, OwnerId int, Content varchar(20))
create table #Comments (Id int, PostId int, CommentData varchar(20))
insert #Users values(99, 'Sam')
insert #Users values(2, 'I am')
insert #Posts values(1, 99, 'Sams Post1')
insert #Posts values(2, 99, 'Sams Post2')
insert #Posts values(3, null, 'no ones post')
insert #Comments values(1, 1, 'Comment 1')"
;
connection
.
Execute
(
createSql
);
var
sql
=
@"SELECT p.* FROM #Posts p
select p.*, u.Id, u.Name + '0' Name, c.Id, c.CommentData from #Posts p
left join #Users u on u.Id = p.OwnerId
left join #Comments c on c.postId = p.Id
where p.Id = 1
Order by p.Id"
;
var
grid
=
connection
.
QueryMultiple
(
sql
);
var
post1
=
grid
.
Read
<
Post
>().
ToList
();
var
post2
=
grid
.
Read
<
Post
,
User
,
Comment
,
Post
>((
post
,
user
,
comment
)
=>
{
post
.
Owner
=
user
;
post
.
Comment
=
comment
;
return
post
;
}).
SingleOrDefault
();
post2
.
Comment
.
Id
.
IsEqualTo
(
1
);
post2
.
Owner
.
Id
.
IsEqualTo
(
99
);
connection
.
Execute
(
"drop table #Users drop table #Posts drop table #Comments"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment