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
b30bcab7
Commit
b30bcab7
authored
Apr 08, 2011
by
Sam Saffron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove orm lite .. broken
add support for multi dbs, keys on connection string
parent
9492f3f6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
8 deletions
+18
-8
PerformanceTests.cs
PerformanceTests.cs
+9
-3
SqlMapper.cs
SqlMapper.cs
+9
-5
No files found.
PerformanceTests.cs
View file @
b30bcab7
...
...
@@ -138,9 +138,15 @@ public void Run(int iterations)
tests
.
Add
(
id
=>
db1
.
SetCommand
(
"select * from Posts where Id = @id"
,
db1
.
Parameter
(
"id"
,
id
)).
ExecuteList
<
Post
>(),
"BLToolkit"
);
//ServiceStack.OrmLite Provider:
OrmLiteConfig
.
DialectProvider
=
SqlServerOrmLiteDialectProvider
.
Instance
;
//Using SQL Server
IDbCommand
ormLiteCmd
=
Program
.
GetOpenConnection
().
CreateCommand
();
tests
.
Add
(
id
=>
ormLiteCmd
.
Select
<
Post
>(
"select * from Posts where Id = {0}"
,
id
),
"ServiceStack.OrmLite SQL Query"
);
/*
* Unhandled Exception: System.FormatException: Input string was not in a correct f
ormat.
at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffe
r& number, NumberFormatInfo info, Boolean parseDecimal)
*/
// OrmLiteConfig.DialectProvider = SqlServerOrmLiteDialectProvider.Instance; //Using SQL Server
// IDbCommand ormLiteCmd = Program.GetOpenConnection().CreateCommand();
// tests.Add(id => ormLiteCmd.Select<Post>("select * from Posts where Id = {0}", id), "ServiceStack.OrmLite SQL Query");
// HAND CODED
...
...
SqlMapper.cs
View file @
b30bcab7
...
...
@@ -99,16 +99,18 @@ public static ParamInfo Create(string name, DbType type, object val)
private
class
Identity
:
IEquatable
<
Identity
>
{
public
String
ConnectionString
{
get
{
return
connectionString
;}
}
public
Type
Type
{
get
{
return
type
;
}
}
public
string
Sql
{
get
{
return
sql
;
}
}
internal
Identity
(
string
sql
,
Type
type
)
internal
Identity
(
string
sql
,
IDbConnection
cnn
,
Type
type
)
{
this
.
sql
=
sql
;
this
.
connectionString
=
cnn
.
ConnectionString
;
this
.
type
=
type
;
hashCode
=
17
;
// we *know* we are using this in a dictionary, so pre-compute this
hashCode
=
hashCode
*
23
+
(
sql
==
null
?
0
:
sql
.
GetHashCode
());
hashCode
=
hashCode
*
23
+
(
type
==
null
?
0
:
type
.
GetHashCode
());
hashCode
=
hashCode
*
23
+
(
connectionString
==
null
?
0
:
connectionString
.
GetHashCode
());
}
public
override
bool
Equals
(
object
obj
)
{
...
...
@@ -117,6 +119,7 @@ public override bool Equals(object obj)
private
readonly
string
sql
;
private
readonly
int
hashCode
;
private
readonly
Type
type
;
private
readonly
string
connectionString
;
public
override
int
GetHashCode
()
{
return
hashCode
;
...
...
@@ -124,7 +127,7 @@ public override int GetHashCode()
public
bool
Equals
(
Identity
other
)
{
return
other
!=
null
&&
this
.
type
==
other
.
type
&&
sql
==
other
.
sql
;
&&
sql
==
other
.
sql
&&
connectionString
==
other
.
connectionString
;
}
}
...
...
@@ -144,7 +147,7 @@ static class DynamicStub
public
static
List
<
dynamic
>
ExecuteMapperQuery
(
this
IDbConnection
cnn
,
string
sql
,
object
param
=
null
,
SqlTransaction
transaction
=
null
)
{
var
identity
=
new
Identity
(
sql
,
DynamicStub
.
Type
);
var
identity
=
new
Identity
(
sql
,
cnn
,
DynamicStub
.
Type
);
var
list
=
new
List
<
dynamic
>();
using
(
var
reader
=
GetReader
(
cnn
,
transaction
,
sql
,
GetParamInfo
(
param
)))
...
...
@@ -161,9 +164,10 @@ public static List<dynamic> ExecuteMapperQuery (this IDbConnection cnn, string s
public
static
List
<
T
>
ExecuteMapperQuery
<
T
>(
this
IDbConnection
cnn
,
string
sql
,
object
param
=
null
,
SqlTransaction
transaction
=
null
)
{
var
identity
=
new
Identity
(
sql
,
typeof
(
T
));
var
identity
=
new
Identity
(
sql
,
cnn
,
typeof
(
T
));
var
rval
=
new
List
<
T
>();
using
(
var
reader
=
GetReader
(
cnn
,
transaction
,
sql
,
GetParamInfo
(
param
)))
{
Func
<
IDataReader
,
T
>
deserializer
=
GetDeserializer
<
T
>(
identity
,
reader
);
...
...
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