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
ae71b7be
Commit
ae71b7be
authored
Nov 15, 2012
by
Sam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #60 from bundy845/master
Allows a class to have a reserved word as a column name.
parents
8b405c70
7fd9b973
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
2 deletions
+23
-2
Program.cs
Dapper.Contrib.Tests/Program.cs
+1
-0
Tests.cs
Dapper.Contrib.Tests/Tests.cs
+21
-1
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+1
-1
No files found.
Dapper.Contrib.Tests/Program.cs
View file @
ae71b7be
...
@@ -32,6 +32,7 @@ private static void Setup()
...
@@ -32,6 +32,7 @@ private static void Setup()
connection
.
Open
();
connection
.
Open
();
connection
.
Execute
(
@" create table Users (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, Age int not null) "
);
connection
.
Execute
(
@" create table Users (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, Age int not null) "
);
connection
.
Execute
(
@" create table Automobiles (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null) "
);
connection
.
Execute
(
@" create table Automobiles (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null) "
);
connection
.
Execute
(
@" create table Results (Id int IDENTITY(1,1) not null, Name nvarchar(100) not null, [Order] int not null) "
);
}
}
Console
.
WriteLine
(
"Created database"
);
Console
.
WriteLine
(
"Created database"
);
}
}
...
...
Dapper.Contrib.Tests/Tests.cs
View file @
ae71b7be
...
@@ -33,6 +33,14 @@ public class Car
...
@@ -33,6 +33,14 @@ public class Car
public
string
Name
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
}
}
[
Table
(
"Results"
)]
public
class
Result
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
public
int
Order
{
get
;
set
;
}
}
public
class
Tests
public
class
Tests
{
{
private
IDbConnection
GetOpenConnection
()
private
IDbConnection
GetOpenConnection
()
...
@@ -75,7 +83,7 @@ public void InsertGetUpdate()
...
@@ -75,7 +83,7 @@ public void InsertGetUpdate()
{
{
using
(
var
connection
=
GetOpenConnection
())
using
(
var
connection
=
GetOpenConnection
())
{
{
connection
.
Get
<
I
User
>(
3
).
IsNull
();
connection
.
Get
<
User
>(
3
).
IsNull
();
var
id
=
connection
.
Insert
(
new
User
{
Name
=
"Adam"
,
Age
=
10
});
var
id
=
connection
.
Insert
(
new
User
{
Name
=
"Adam"
,
Age
=
10
});
...
@@ -161,5 +169,17 @@ public void BuilderTemplateWOComposition()
...
@@ -161,5 +169,17 @@ public void BuilderTemplateWOComposition()
throw
new
Exception
(
"Query failed"
);
throw
new
Exception
(
"Query failed"
);
}
}
}
}
public
void
InsertFieldWithReservedName
()
{
using
(
var
conneciton
=
GetOpenConnection
())
{
var
id
=
conneciton
.
Insert
(
new
Result
()
{
Name
=
"Adam"
,
Order
=
1
});
var
result
=
conneciton
.
Get
<
Result
>(
id
);
result
.
Order
.
IsEqualTo
(
1
);
}
}
}
}
}
}
Dapper.Contrib/SqlMapperExtensions.cs
View file @
ae71b7be
...
@@ -180,7 +180,7 @@ private static string GetTableName(Type type)
...
@@ -180,7 +180,7 @@ private static string GetTableName(Type type)
for
(
var
i
=
0
;
i
<
allPropertiesExceptKey
.
Count
();
i
++)
for
(
var
i
=
0
;
i
<
allPropertiesExceptKey
.
Count
();
i
++)
{
{
var
property
=
allPropertiesExceptKey
.
ElementAt
(
i
);
var
property
=
allPropertiesExceptKey
.
ElementAt
(
i
);
sbColumnList
.
Append
(
property
.
Name
);
sbColumnList
.
Append
Format
(
"[{0}]"
,
property
.
Name
);
if
(
i
<
allPropertiesExceptKey
.
Count
()
-
1
)
if
(
i
<
allPropertiesExceptKey
.
Count
()
-
1
)
sbColumnList
.
Append
(
", "
);
sbColumnList
.
Append
(
", "
);
}
}
...
...
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