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
a46ab4e7
Commit
a46ab4e7
authored
Nov 10, 2015
by
Nick Craver
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #371 from janzakrzewskipl/master
fixed GetAll when used with ExplicitKey
parents
45df8d8d
e447523d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
4 deletions
+18
-4
Tests.cs
Dapper.Contrib.Tests/Tests.cs
+13
-0
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+5
-4
No files found.
Dapper.Contrib.Tests/Tests.cs
View file @
a46ab4e7
...
...
@@ -153,6 +153,19 @@ public void InsertGetUpdateDeleteWithExplicitKey()
}
}
public
void
GetAllWithExplicitKey
()
{
using
(
var
connection
=
GetOpenConnection
())
{
var
guid
=
Guid
.
NewGuid
().
ToString
();
var
o1
=
new
ObjectX
{
ObjectXId
=
guid
,
Name
=
"Foo"
};
connection
.
Insert
(
o1
);
var
objectXs
=
connection
.
GetAll
<
ObjectX
>();
objectXs
.
Count
().
IsEqualTo
(
1
);
}
}
public
void
ShortIdentity
()
{
using
(
var
connection
=
GetOpenConnection
())
...
...
Dapper.Contrib/SqlMapperExtensions.cs
View file @
a46ab4e7
...
...
@@ -201,10 +201,11 @@ private static bool IsWriteable(PropertyInfo pi)
if
(!
GetQueries
.
TryGetValue
(
cacheType
.
TypeHandle
,
out
sql
))
{
var
keys
=
KeyPropertiesCache
(
type
);
if
(
keys
.
Count
()
>
1
)
throw
new
DataException
(
"Get<T> only supports an entity with a single [Key] property"
);
if
(!
keys
.
Any
())
throw
new
DataException
(
"Get<T> only supports en entity with a [Key] property"
);
var
explicitKeys
=
ExplicitKeyPropertiesCache
(
type
);
if
(
keys
.
Count
()
>
1
||
explicitKeys
.
Count
()
>
1
)
throw
new
DataException
(
"Get<T> only supports an entity with a single [Key] or [ExplicitKey] property"
);
if
(!
keys
.
Any
()
&&
!
explicitKeys
.
Any
())
throw
new
DataException
(
"Get<T> only supports an entity with a [Key] or an [ExplicitKey] property"
);
var
name
=
GetTableName
(
type
);
...
...
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