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
61707905
Commit
61707905
authored
Sep 21, 2019
by
james-hester-ah
Committed by
Nick Craver
Sep 21, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue #418 for DeleteAsync (#1309)
Fix issue #418 for DeleteAsync (with tests)
parent
9282ef28
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
SqlMapperExtensions.Async.cs
Dapper.Contrib/SqlMapperExtensions.Async.cs
+4
-4
TestSuite.Async.cs
Dapper.Tests.Contrib/TestSuite.Async.cs
+11
-0
No files found.
Dapper.Contrib/SqlMapperExtensions.Async.cs
View file @
61707905
...
...
@@ -307,18 +307,18 @@ public static partial class SqlMapperExtensions
throw
new
ArgumentException
(
"Entity must have at least one [Key] or [ExplicitKey] property"
);
var
name
=
GetTableName
(
type
);
keyProperties
.
AddRange
(
explicitKeyProperties
);
var
allKeyProperties
=
keyProperties
.
Concat
(
explicitKeyProperties
).
ToList
(
);
var
sb
=
new
StringBuilder
();
sb
.
AppendFormat
(
"DELETE FROM {0} WHERE "
,
name
);
var
adapter
=
GetFormatter
(
connection
);
for
(
var
i
=
0
;
i
<
k
eyProperties
.
Count
;
i
++)
for
(
var
i
=
0
;
i
<
allK
eyProperties
.
Count
;
i
++)
{
var
property
=
k
eyProperties
[
i
];
var
property
=
allK
eyProperties
[
i
];
adapter
.
AppendColumnNameEqualsValue
(
sb
,
property
.
Name
);
if
(
i
<
k
eyProperties
.
Count
-
1
)
if
(
i
<
allK
eyProperties
.
Count
-
1
)
sb
.
Append
(
" AND "
);
}
var
deleted
=
await
connection
.
ExecuteAsync
(
sb
.
ToString
(),
entityToDelete
,
transaction
,
commandTimeout
).
ConfigureAwait
(
false
);
...
...
Dapper.Tests.Contrib/TestSuite.Async.cs
View file @
61707905
...
...
@@ -83,6 +83,17 @@ public async Task TypeWithGenericParameterCanBeDeletedAsync()
}
}
[
Fact
]
public
async
Task
GetAsyncSucceedsAfterDeleteAsyncWhenExplicitKeyPresent
()
{
using
(
var
connection
=
GetOpenConnection
())
{
await
connection
.
DeleteAsync
(
new
ObjectX
{
ObjectXId
=
Guid
.
NewGuid
().
ToString
()
}).
ConfigureAwait
(
false
);
var
retrieved
=
await
connection
.
GetAsync
<
ObjectX
>(
Guid
.
NewGuid
().
ToString
()).
ConfigureAwait
(
false
);
Assert
.
Null
(
retrieved
);
}
}
/// <summary>
/// Tests for issue #351
/// </summary>
...
...
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