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
c9f4b535
Commit
c9f4b535
authored
Apr 02, 2020
by
mgravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for #1431
parent
4ad80f88
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
Dapper.Tests.csproj
Dapper.Tests/Dapper.Tests.csproj
+1
-1
Issue1431.cs
Dapper.Tests/Issues/Issue1431.cs
+65
-0
No files found.
Dapper.Tests/Dapper.Tests.csproj
View file @
c9f4b535
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<AssemblyName>Dapper.Tests</AssemblyName>
<AssemblyName>Dapper.Tests</AssemblyName>
<Description>Dapper Core Test Suite</Description>
<Description>Dapper Core Test Suite</Description>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<TargetFrameworks>netcoreapp2.1;net462;net472</TargetFrameworks>
<TargetFrameworks>netcoreapp2.1;net462;net472
;netcoreapp3.1
</TargetFrameworks>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<DefineConstants>$(DefineConstants);MSSQLCLIENT</DefineConstants>
<DefineConstants>$(DefineConstants);MSSQLCLIENT</DefineConstants>
</PropertyGroup>
</PropertyGroup>
...
...
Dapper.Tests/Issues/Issue1431.cs
0 → 100644
View file @
c9f4b535
using
System.Collections.Generic
;
using
System.Data
;
using
System.Threading.Tasks
;
using
Xunit
;
namespace
Dapper.Tests.Issues
{
[
Collection
(
"Issues"
)]
public
sealed
class
SystemSqlClientIssue1431
:
Issue1431
<
SystemSqlClientProvider
>
{
}
#if MSSQLCLIENT
[
Collection
(
"Issues"
)]
public
sealed
class
MicrosoftSqlClientIssue1431
:
Issue1431
<
MicrosoftSqlClientProvider
>
{
}
#endif
public
abstract
class
Issue1431
<
TProvider
>
:
TestBase
<
TProvider
>
where
TProvider
:
DatabaseProvider
{
[
Fact
]
public
async
Task
CanUseDataTableTVP
()
{
InitSchema
();
var
result
=
(
await
GetSomeData
(
new
[]
{
1
,
2
,
3
}));
Assert
.
Equal
(
"1,2,3"
,
string
.
Join
(
","
,
result
));
}
private
void
InitSchema
()
{
try
{
connection
.
Execute
(
"drop proc Issue1431_GetDataWithTVP"
);
}
catch
{
}
try
{
connection
.
Execute
(
"drop type Issue1431_IdFilter"
);
}
catch
{
}
connection
.
Execute
(
"CREATE TYPE Issue1431_IdFilter AS TABLE (Id int NOT NULL)"
);
connection
.
Execute
(
@"CREATE PROC Issue1431_GetDataWithTVP (@IdFilter Issue1431_IdFilter READONLY)
AS
BEGIN
SET NOCOUNT ON;
SELECT Id
FROM @IdFilter;
END"
);
}
public
async
Task
<
IEnumerable
<
int
>>
GetSomeData
(
IEnumerable
<
int
>
idFilter
)
{
var
dataTable
=
GetDataTable
(
idFilter
);
var
dynamicParams
=
new
DynamicParameters
(
new
{
IdFilter
=
dataTable
});
return
await
connection
.
QueryAsync
<
int
>(
"Issue1431_GetDataWithTVP"
,
dynamicParams
,
commandType
:
CommandType
.
StoredProcedure
);
}
private
static
DataTable
GetDataTable
(
IEnumerable
<
int
>
idFilter
)
{
var
dt
=
new
DataTable
();
dt
.
Columns
.
Add
(
"Id"
,
typeof
(
int
));
if
(
idFilter
==
null
)
return
dt
;
foreach
(
var
id
in
idFilter
)
{
dt
.
Rows
.
Add
(
id
);
}
return
dt
;
}
}
}
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