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
16d86918
Commit
16d86918
authored
Dec 01, 2016
by
Phelipe de Sterlich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added firebird support
added firebird sql adapter to allow record insert and key retrieving
parent
4b459895
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+33
-0
No files found.
Dapper.Contrib/SqlMapperExtensions.cs
View file @
16d86918
...
...
@@ -49,6 +49,7 @@ public interface ITableNameMapper
{
"npgsqlconnection"
,
new
PostgresAdapter
()},
{
"sqliteconnection"
,
new
SQLiteAdapter
()},
{
"mysqlconnection"
,
new
MySqlAdapter
()},
{
"fbconnection"
,
new
FbAdapter
()
}
};
private
static
List
<
PropertyInfo
>
ComputedPropertiesCache
(
Type
type
)
...
...
@@ -864,3 +865,35 @@ public void AppendColumnNameEqualsValue(StringBuilder sb, string columnName)
sb
.
AppendFormat
(
"\"{0}\" = @{1}"
,
columnName
,
columnName
);
}
}
public
partial
class
FbAdapter
:
ISqlAdapter
{
public
int
Insert
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
string
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
{
var
cmd
=
$"insert into
{
tableName
}
(
{
columnList
}
) values (
{
parameterList
}
)"
;
connection
.
Execute
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
var
propertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
var
keyName
=
propertyInfos
.
First
().
Name
;
var
r
=
connection
.
Query
(
$"SELECT FIRST 1
{
keyName
}
ID FROM
{
tableName
}
ORDER BY
{
keyName
}
DESC"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
var
id
=
r
.
First
().
ID
;
if
(
id
==
null
)
return
0
;
if
(!
propertyInfos
.
Any
())
return
Convert
.
ToInt32
(
id
);
var
idp
=
propertyInfos
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
return
Convert
.
ToInt32
(
id
);
}
public
void
AppendColumnName
(
StringBuilder
sb
,
string
columnName
)
{
sb
.
AppendFormat
(
"{0}"
,
columnName
);
}
public
void
AppendColumnNameEqualsValue
(
StringBuilder
sb
,
string
columnName
)
{
sb
.
AppendFormat
(
"{0} = @{1}"
,
columnName
,
columnName
);
}
}
\ No newline at end of file
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