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
a0ba65a4
Commit
a0ba65a4
authored
Nov 04, 2015
by
johandanforth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed missing check for explicit key in Contrib GetaAync()
parent
7f22bff5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
SqlMapperExtensionsAsync.cs
Dapper.Contrib NET45/SqlMapperExtensionsAsync.cs
+7
-6
No files found.
Dapper.Contrib NET45/SqlMapperExtensionsAsync.cs
View file @
a0ba65a4
...
@@ -32,17 +32,18 @@ public static partial class SqlMapperExtensions
...
@@ -32,17 +32,18 @@ public static partial class SqlMapperExtensions
if
(!
GetQueries
.
TryGetValue
(
type
.
TypeHandle
,
out
sql
))
if
(!
GetQueries
.
TryGetValue
(
type
.
TypeHandle
,
out
sql
))
{
{
var
keys
=
KeyPropertiesCache
(
type
);
var
keys
=
KeyPropertiesCache
(
type
);
if
(
keys
.
Count
()
>
1
)
var
explicitKeys
=
ExplicitKeyPropertiesCache
(
type
);
throw
new
DataException
(
"Get<T> only supports an entity with a single [Key] property"
);
if
(
keys
.
Count
()
>
1
||
explicitKeys
.
Count
()
>
1
)
if
(!
keys
.
Any
())
throw
new
DataException
(
"Get<T> only supports an entity with a single [Key] or [ExplicitKey] property"
);
throw
new
DataException
(
"Get<T> only supports en entity with a [Key] property"
);
if
(!
keys
.
Any
()
&&
!
explicitKeys
.
Any
())
throw
new
DataException
(
"Get<T> only supports an entity with a [Key] or an [ExplicitKey] property"
);
var
onlyKey
=
k
eys
.
First
();
var
key
=
keys
.
Any
()
?
keys
.
First
()
:
explicitK
eys
.
First
();
var
name
=
GetTableName
(
type
);
var
name
=
GetTableName
(
type
);
// TODO: query information schema and only select fields that are both in information schema and underlying class / interface
// TODO: query information schema and only select fields that are both in information schema and underlying class / interface
sql
=
"select * from "
+
name
+
" where "
+
onlyK
ey
.
Name
+
" = @id"
;
sql
=
"select * from "
+
name
+
" where "
+
k
ey
.
Name
+
" = @id"
;
GetQueries
[
type
.
TypeHandle
]
=
sql
;
GetQueries
[
type
.
TypeHandle
]
=
sql
;
}
}
...
...
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