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
3ad263d2
Commit
3ad263d2
authored
Oct 14, 2015
by
johandanforth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes for #336 escape column names
parent
2f7125a0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
147 additions
and
56 deletions
+147
-56
SqlMapperExtensionsAsync.cs
Dapper.Contrib NET45/SqlMapperExtensionsAsync.cs
+43
-25
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+104
-31
No files found.
Dapper.Contrib NET45/SqlMapperExtensionsAsync.cs
View file @
3ad263d2
...
@@ -305,14 +305,12 @@ public async Task<int> InsertAsync(IDbConnection connection, IDbTransaction tran
...
@@ -305,14 +305,12 @@ public async Task<int> InsertAsync(IDbConnection connection, IDbTransaction tran
if
(
first
==
null
||
first
.
id
==
null
)
return
0
;
if
(
first
==
null
||
first
.
id
==
null
)
return
0
;
var
id
=
(
int
)
first
.
id
;
var
id
=
(
int
)
first
.
id
;
var
propertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(!
propertyInfos
.
Any
())
return
id
;
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
var
idProperty
=
propertyInfos
.
First
();
if
(
idProperty
.
PropertyType
.
Name
==
"Int16"
)
//for short id/key types issue #196
idProperty
.
SetValue
(
entityToInsert
,
(
Int16
)
id
,
null
);
else
idProperty
.
SetValue
(
entityToInsert
,
id
,
null
);
return
id
;
return
id
;
}
}
}
}
...
@@ -323,20 +321,39 @@ public async Task<int> InsertAsync(IDbConnection connection, IDbTransaction tran
...
@@ -323,20 +321,39 @@ public async Task<int> InsertAsync(IDbConnection connection, IDbTransaction tran
{
{
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
await
connection
.
ExecuteAsync
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
).
ConfigureAwait
(
false
);
await
connection
.
ExecuteAsync
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
).
ConfigureAwait
(
false
);
var
r
=
await
connection
.
QueryAsync
<
dynamic
>(
"select @@IDENTITY id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
).
ConfigureAwait
(
false
);
var
r
=
(
await
connection
.
QueryAsync
<
dynamic
>(
"select @@IDENTITY id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
).
ConfigureAwait
(
false
)).
ToList
();
if
(
r
.
First
()
==
null
||
r
.
First
().
id
==
null
)
return
0
;
var
id
=
(
int
)
r
.
First
().
id
;
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
return
id
;
}
}
public
partial
class
MySqlAdapter
:
ISqlAdapter
{
public
async
Task
<
int
>
InsertAsync
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
string
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
{
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
await
connection
.
ExecuteAsync
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
).
ConfigureAwait
(
false
);
var
r
=
await
connection
.
QueryAsync
<
dynamic
>(
"select LAST_INSERT_ID()"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
).
ConfigureAwait
(
false
);
var
id
=
r
.
First
().
id
;
var
id
=
r
.
First
().
id
;
if
(
id
==
null
)
return
0
;
if
(
id
==
null
)
return
0
;
var
keyPropertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(
keyPropertyInfos
.
Any
())
if
(!
pi
.
Any
())
return
id
;
{
var
idProperty
=
keyPropertyInfos
.
First
();
var
idp
=
pi
.
First
();
if
(
idProperty
.
PropertyType
.
Name
==
"Int16"
)
//for short id/key types issue #196
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
idProperty
.
SetValue
(
entityToInsert
,
(
Int16
)
id
,
null
);
else
return
id
;
idProperty
.
SetValue
(
entityToInsert
,
(
int
)
id
,
null
);
}
return
(
int
)
id
;
}
}
}
}
...
@@ -385,15 +402,16 @@ public partial class SQLiteAdapter
...
@@ -385,15 +402,16 @@ public partial class SQLiteAdapter
public
async
Task
<
int
>
InsertAsync
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
public
async
Task
<
int
>
InsertAsync
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
{
{
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2}); select last_insert_rowid() id"
,
tableName
,
columnList
,
parameterList
);
var
multi
=
await
connection
.
QueryMultipleAsync
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
await
connection
.
ExecuteAsync
(
cmd
,
entityToInsert
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
).
ConfigureAwait
(
false
);
var
id
=
(
int
)
multi
.
Read
().
First
().
id
;
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
var
r
=
await
connection
.
QueryAsync
<
dynamic
>(
"select last_insert_rowid() id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
).
ConfigureAwait
(
false
);
var
id
=
(
int
)
r
.
First
().
id
;
var
propertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(
propertyInfos
.
Any
())
propertyInfos
.
First
().
SetValue
(
entityToInsert
,
id
,
null
);
return
id
;
return
id
;
}
}
}
}
Dapper.Contrib/SqlMapperExtensions.cs
View file @
3ad263d2
...
@@ -42,7 +42,8 @@ public interface ITableNameMapper
...
@@ -42,7 +42,8 @@ public interface ITableNameMapper
{
"sqlconnection"
,
new
SqlServerAdapter
()},
{
"sqlconnection"
,
new
SqlServerAdapter
()},
{
"sqlceconnection"
,
new
SqlCeServerAdapter
()},
{
"sqlceconnection"
,
new
SqlCeServerAdapter
()},
{
"npgsqlconnection"
,
new
PostgresAdapter
()},
{
"npgsqlconnection"
,
new
PostgresAdapter
()},
{
"sqliteconnection"
,
new
SQLiteAdapter
()}
{
"sqliteconnection"
,
new
SQLiteAdapter
()},
{
"mysqlconnection"
,
new
MySqlAdapter
()},
};
};
private
static
List
<
PropertyInfo
>
ComputedPropertiesCache
(
Type
type
)
private
static
List
<
PropertyInfo
>
ComputedPropertiesCache
(
Type
type
)
...
@@ -289,10 +290,12 @@ private static string GetTableName(Type type)
...
@@ -289,10 +290,12 @@ private static string GetTableName(Type type)
var
computedProperties
=
ComputedPropertiesCache
(
type
);
var
computedProperties
=
ComputedPropertiesCache
(
type
);
var
allPropertiesExceptKeyAndComputed
=
allProperties
.
Except
(
keyProperties
.
Union
(
computedProperties
)).
ToList
();
var
allPropertiesExceptKeyAndComputed
=
allProperties
.
Except
(
keyProperties
.
Union
(
computedProperties
)).
ToList
();
var
adapter
=
GetFormatter
(
connection
);
for
(
var
i
=
0
;
i
<
allPropertiesExceptKeyAndComputed
.
Count
();
i
++)
for
(
var
i
=
0
;
i
<
allPropertiesExceptKeyAndComputed
.
Count
();
i
++)
{
{
var
property
=
allPropertiesExceptKeyAndComputed
.
ElementAt
(
i
);
var
property
=
allPropertiesExceptKeyAndComputed
.
ElementAt
(
i
);
sbColumnList
.
AppendFormat
(
"[{0}]"
,
property
.
Name
);
adapter
.
AppendColumnName
(
sbColumnList
,
property
.
Name
);
//fix for issue #336
if
(
i
<
allPropertiesExceptKeyAndComputed
.
Count
()
-
1
)
if
(
i
<
allPropertiesExceptKeyAndComputed
.
Count
()
-
1
)
sbColumnList
.
Append
(
", "
);
sbColumnList
.
Append
(
", "
);
}
}
...
@@ -312,7 +315,6 @@ private static string GetTableName(Type type)
...
@@ -312,7 +315,6 @@ private static string GetTableName(Type type)
if
(!
isList
)
//single entity
if
(!
isList
)
//single entity
{
{
var
adapter
=
GetFormatter
(
connection
);
returnVal
=
adapter
.
Insert
(
connection
,
transaction
,
commandTimeout
,
name
,
sbColumnList
.
ToString
(),
returnVal
=
adapter
.
Insert
(
connection
,
transaction
,
commandTimeout
,
name
,
sbColumnList
.
ToString
(),
sbParameterList
.
ToString
(),
keyProperties
,
entityToInsert
);
sbParameterList
.
ToString
(),
keyProperties
,
entityToInsert
);
}
}
...
@@ -361,10 +363,12 @@ private static string GetTableName(Type type)
...
@@ -361,10 +363,12 @@ private static string GetTableName(Type type)
var
computedProperties
=
ComputedPropertiesCache
(
type
);
var
computedProperties
=
ComputedPropertiesCache
(
type
);
var
nonIdProps
=
allProperties
.
Except
(
keyProperties
.
Union
(
computedProperties
)).
ToList
();
var
nonIdProps
=
allProperties
.
Except
(
keyProperties
.
Union
(
computedProperties
)).
ToList
();
var
adapter
=
GetFormatter
(
connection
);
for
(
var
i
=
0
;
i
<
nonIdProps
.
Count
();
i
++)
for
(
var
i
=
0
;
i
<
nonIdProps
.
Count
();
i
++)
{
{
var
property
=
nonIdProps
.
ElementAt
(
i
);
var
property
=
nonIdProps
.
ElementAt
(
i
);
sb
.
AppendFormat
(
"[{0}] = @{1}"
,
property
.
Name
,
property
.
Name
);
adapter
.
AppendColumnNameEqualsValue
(
sb
,
property
.
Name
);
//fix for issue #336
if
(
i
<
nonIdProps
.
Count
()
-
1
)
if
(
i
<
nonIdProps
.
Count
()
-
1
)
sb
.
AppendFormat
(
", "
);
sb
.
AppendFormat
(
", "
);
}
}
...
@@ -372,7 +376,7 @@ private static string GetTableName(Type type)
...
@@ -372,7 +376,7 @@ private static string GetTableName(Type type)
for
(
var
i
=
0
;
i
<
keyProperties
.
Count
();
i
++)
for
(
var
i
=
0
;
i
<
keyProperties
.
Count
();
i
++)
{
{
var
property
=
keyProperties
.
ElementAt
(
i
);
var
property
=
keyProperties
.
ElementAt
(
i
);
sb
.
AppendFormat
(
"[{0}] = @{1}"
,
property
.
Name
,
property
.
Name
);
adapter
.
AppendColumnNameEqualsValue
(
sb
,
property
.
Name
);
//fix for issue #336
if
(
i
<
keyProperties
.
Count
()
-
1
)
if
(
i
<
keyProperties
.
Count
()
-
1
)
sb
.
AppendFormat
(
" and "
);
sb
.
AppendFormat
(
" and "
);
}
}
...
@@ -408,10 +412,12 @@ private static string GetTableName(Type type)
...
@@ -408,10 +412,12 @@ private static string GetTableName(Type type)
var
sb
=
new
StringBuilder
();
var
sb
=
new
StringBuilder
();
sb
.
AppendFormat
(
"delete from {0} where "
,
name
);
sb
.
AppendFormat
(
"delete from {0} where "
,
name
);
var
adapter
=
GetFormatter
(
connection
);
for
(
var
i
=
0
;
i
<
keyProperties
.
Count
();
i
++)
for
(
var
i
=
0
;
i
<
keyProperties
.
Count
();
i
++)
{
{
var
property
=
keyProperties
.
ElementAt
(
i
);
var
property
=
keyProperties
.
ElementAt
(
i
);
sb
.
AppendFormat
(
"[{0}] = @{1}"
,
property
.
Name
,
property
.
Name
);
adapter
.
AppendColumnNameEqualsValue
(
sb
,
property
.
Name
);
//fix for issue #336
if
(
i
<
keyProperties
.
Count
()
-
1
)
if
(
i
<
keyProperties
.
Count
()
-
1
)
sb
.
AppendFormat
(
" and "
);
sb
.
AppendFormat
(
" and "
);
}
}
...
@@ -653,6 +659,10 @@ public class ComputedAttribute : Attribute
...
@@ -653,6 +659,10 @@ public class ComputedAttribute : Attribute
public
partial
interface
ISqlAdapter
public
partial
interface
ISqlAdapter
{
{
int
Insert
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
);
int
Insert
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
);
//new methods for issue #336
void
AppendColumnName
(
StringBuilder
sb
,
string
columnName
);
void
AppendColumnNameEqualsValue
(
StringBuilder
sb
,
string
columnName
);
}
}
public
partial
class
SqlServerAdapter
:
ISqlAdapter
public
partial
class
SqlServerAdapter
:
ISqlAdapter
...
@@ -666,16 +676,24 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
...
@@ -666,16 +676,24 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
if
(
first
==
null
||
first
.
id
==
null
)
return
0
;
if
(
first
==
null
||
first
.
id
==
null
)
return
0
;
var
id
=
(
int
)
first
.
id
;
var
id
=
(
int
)
first
.
id
;
var
propertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(!
propertyInfos
.
Any
())
return
id
;
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
var
idProperty
=
propertyInfos
.
First
();
if
(
idProperty
.
PropertyType
.
Name
==
"Int16"
)
//for short id/key types issue #196
idProperty
.
SetValue
(
entityToInsert
,
(
Int16
)
id
,
null
);
else
idProperty
.
SetValue
(
entityToInsert
,
id
,
null
);
return
id
;
return
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
);
}
}
}
public
partial
class
SqlCeServerAdapter
:
ISqlAdapter
public
partial
class
SqlCeServerAdapter
:
ISqlAdapter
...
@@ -684,20 +702,58 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
...
@@ -684,20 +702,58 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
{
{
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
connection
.
Execute
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
connection
.
Execute
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
var
r
=
connection
.
Query
(
"select @@IDENTITY id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
var
r
=
connection
.
Query
(
"select @@IDENTITY id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
).
ToList
();
if
(
r
.
First
().
id
==
null
)
return
0
;
var
id
=
(
int
)
r
.
First
().
id
;
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
return
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
);
}
}
public
partial
class
MySqlAdapter
:
ISqlAdapter
{
public
int
Insert
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
{
var
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
connection
.
Execute
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
var
r
=
connection
.
Query
(
"Select LAST_INSERT_ID()"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
var
id
=
r
.
First
().
id
;
var
id
=
r
.
First
().
id
;
if
(
id
==
null
)
return
0
;
if
(
id
==
null
)
return
0
;
var
keyPropertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(
keyPropertyInfos
.
Any
())
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
return
id
;
}
public
void
AppendColumnName
(
StringBuilder
sb
,
string
columnName
)
{
{
var
idProperty
=
keyPropertyInfos
.
First
();
sb
.
AppendFormat
(
"`{0}`"
,
columnName
);
if
(
idProperty
.
PropertyType
.
Name
==
"Int16"
)
//for short id/key types issue #196
idProperty
.
SetValue
(
entityToInsert
,
(
Int16
)
id
,
null
);
else
idProperty
.
SetValue
(
entityToInsert
,
(
int
)
id
,
null
);
}
}
return
(
int
)
id
;
public
void
AppendColumnNameEqualsValue
(
StringBuilder
sb
,
string
columnName
)
{
sb
.
AppendFormat
(
"`{0}` = @{1}"
,
columnName
,
columnName
);
}
}
}
}
...
@@ -739,6 +795,16 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
...
@@ -739,6 +795,16 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
}
}
return
id
;
return
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
);
}
}
}
public
partial
class
SQLiteAdapter
:
ISqlAdapter
public
partial
class
SQLiteAdapter
:
ISqlAdapter
...
@@ -749,15 +815,22 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
...
@@ -749,15 +815,22 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
var
multi
=
connection
.
QueryMultiple
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
var
multi
=
connection
.
QueryMultiple
(
cmd
,
entityToInsert
,
transaction
,
commandTimeout
);
var
id
=
(
int
)
multi
.
Read
().
First
().
id
;
var
id
=
(
int
)
multi
.
Read
().
First
().
id
;
var
propertyInfos
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
var
pi
=
keyProperties
as
PropertyInfo
[]
??
keyProperties
.
ToArray
();
if
(!
propertyInfos
.
Any
())
return
id
;
if
(!
pi
.
Any
())
return
id
;
var
idp
=
pi
.
First
();
idp
.
SetValue
(
entityToInsert
,
Convert
.
ChangeType
(
id
,
idp
.
PropertyType
),
null
);
var
idProperty
=
propertyInfos
.
First
();
if
(
idProperty
.
PropertyType
.
Name
==
"Int16"
)
//for short id/key types issue #196
idProperty
.
SetValue
(
entityToInsert
,
(
Int16
)
id
,
null
);
else
idProperty
.
SetValue
(
entityToInsert
,
id
,
null
);
return
id
;
return
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
);
}
}
}
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