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
aec9a9d2
Commit
aec9a9d2
authored
May 07, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #109 from majorsilence/sqlite-support
Add SQLiteAdapter
parents
f8abab60
48c111ac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
+22
-2
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+22
-2
No files found.
Dapper.Contrib/SqlMapperExtensions.cs
View file @
aec9a9d2
...
...
@@ -29,7 +29,8 @@ public interface IProxy
private
static
readonly
Dictionary
<
string
,
ISqlAdapter
>
AdapterDictionary
=
new
Dictionary
<
string
,
ISqlAdapter
>()
{
{
"sqlconnection"
,
new
SqlServerAdapter
()},
{
"npgsqlconnection"
,
new
PostgresAdapter
()}
{
"npgsqlconnection"
,
new
PostgresAdapter
()},
{
"sqliteconnection"
,
new
SQLiteAdapter
()}
};
private
static
IEnumerable
<
PropertyInfo
>
ComputedPropertiesCache
(
Type
type
)
{
...
...
@@ -552,3 +553,22 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
return
id
;
}
}
public
class
SQLiteAdapter
:
ISqlAdapter
{
public
int
Insert
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
{
string
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
connection
.
Execute
(
cmd
,
entityToInsert
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
var
r
=
connection
.
Query
(
"select last_insert_rowid() id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
int
id
=
(
int
)
r
.
First
().
id
;
if
(
keyProperties
.
Any
())
keyProperties
.
First
().
SetValue
(
entityToInsert
,
id
,
null
);
return
id
;
}
}
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