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
da7f0dd3
Commit
da7f0dd3
authored
Oct 15, 2015
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'kppullin-defaultStringType'
parents
1e27c363
9c3c52f1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+9
-1
Tests.cs
Tests/Tests.cs
+18
-1
No files found.
Dapper NET40/SqlMapper.cs
View file @
da7f0dd3
...
@@ -5258,6 +5258,11 @@ internal static void Set(IDbDataParameter parameter, DataTable table, string typ
...
@@ -5258,6 +5258,11 @@ internal static void Set(IDbDataParameter parameter, DataTable table, string typ
/// </summary>
/// </summary>
sealed
partial
class
DbString
:
Dapper
.
SqlMapper
.
ICustomQueryParameter
sealed
partial
class
DbString
:
Dapper
.
SqlMapper
.
ICustomQueryParameter
{
{
/// <summary>
/// Default value for IsAnsi.
/// </summary>
public
static
bool
IsAnsiDefault
{
get
;
set
;
}
/// <summary>
/// <summary>
/// A value to set the default value of strings
/// A value to set the default value of strings
/// going through Dapper. Default is 4000, any value larger than this
/// going through Dapper. Default is 4000, any value larger than this
...
@@ -5268,7 +5273,10 @@ sealed partial class DbString : Dapper.SqlMapper.ICustomQueryParameter
...
@@ -5268,7 +5273,10 @@ sealed partial class DbString : Dapper.SqlMapper.ICustomQueryParameter
/// <summary>
/// <summary>
/// Create a new DbString
/// Create a new DbString
/// </summary>
/// </summary>
public
DbString
()
{
Length
=
-
1
;
}
public
DbString
()
{
Length
=
-
1
;
IsAnsi
=
IsAnsiDefault
;
}
/// <summary>
/// <summary>
/// Ansi vs Unicode
/// Ansi vs Unicode
/// </summary>
/// </summary>
...
...
Tests/Tests.cs
View file @
da7f0dd3
...
@@ -1541,6 +1541,23 @@ public void TestDbString()
...
@@ -1541,6 +1541,23 @@ public void TestDbString()
((
int
)
obj
.
f
).
IsEqualTo
(
10
);
((
int
)
obj
.
f
).
IsEqualTo
(
10
);
}
}
public
void
TestDefaultDbStringDbType
()
{
var
origDefaultStringDbType
=
DbString
.
IsAnsiDefault
;
try
{
DbString
.
IsAnsiDefault
=
true
;
var
a
=
new
DbString
{
Value
=
"abcde"
};
var
b
=
new
DbString
{
Value
=
"abcde"
,
IsAnsi
=
false
};
a
.
IsAnsi
.
IsTrue
();
b
.
IsAnsi
.
IsFalse
();
}
finally
{
DbString
.
IsAnsiDefault
=
origDefaultStringDbType
;
}
}
class
Person
class
Person
{
{
public
int
PersonId
{
get
;
set
;
}
public
int
PersonId
{
get
;
set
;
}
...
@@ -3289,7 +3306,7 @@ SELECT @a
...
@@ -3289,7 +3306,7 @@ SELECT @a
connection
.
Query
<
TimeSpan
>(
"#TestProcWithTimeParameter"
,
p
,
commandType
:
CommandType
.
StoredProcedure
).
First
().
IsEqualTo
(
new
TimeSpan
(
10
,
0
,
0
));
connection
.
Query
<
TimeSpan
>(
"#TestProcWithTimeParameter"
,
p
,
commandType
:
CommandType
.
StoredProcedure
).
First
().
IsEqualTo
(
new
TimeSpan
(
10
,
0
,
0
));
}
}
public
void
DbString
()
public
void
DbString
Ansi
()
{
{
var
a
=
connection
.
Query
<
int
>(
"select datalength(@x)"
,
var
a
=
connection
.
Query
<
int
>(
"select datalength(@x)"
,
new
{
x
=
new
DbString
{
Value
=
"abc"
,
IsAnsi
=
true
}
}).
Single
();
new
{
x
=
new
DbString
{
Value
=
"abc"
,
IsAnsi
=
true
}
}).
Single
();
...
...
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