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
ad48bed2
Commit
ad48bed2
authored
Nov 27, 2015
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup
Remove some unused casts, variables, and warnings
parent
e24c472f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
12 deletions
+15
-12
DynamicParameters.CachedOutputSetters.cs
Dapper/DynamicParameters.CachedOutputSetters.cs
+4
-0
DynamicParameters.cs
Dapper/DynamicParameters.cs
+2
-2
SqlMapper.cs
Dapper/SqlMapper.cs
+9
-10
No files found.
Dapper/DynamicParameters.CachedOutputSetters.cs
View file @
ad48bed2
...
...
@@ -4,8 +4,12 @@ namespace Dapper
{
partial
class
DynamicParameters
{
// The type here is used to differentiate the cache by type via generics
// ReSharper disable once UnusedTypeParameter
internal
static
class
CachedOutputSetters
<
T
>
{
// Intentional, abusing generics to get our cache splits
// ReSharper disable once StaticMemberInGenericType
public
static
readonly
Hashtable
Cache
=
new
Hashtable
();
}
}
...
...
Dapper/DynamicParameters.cs
View file @
ad48bed2
...
...
@@ -61,7 +61,7 @@ public DynamicParameters(object template)
/// <param name="param"></param>
public
void
AddDynamicParams
(
object
param
)
{
var
obj
=
param
as
object
;
var
obj
=
param
;
if
(
obj
!=
null
)
{
var
subDynamic
=
obj
as
DynamicParameters
;
...
...
@@ -394,7 +394,7 @@ public DynamicParameters Output<T>(T target, Expression<Func<T, object>> express
var
lookup
=
string
.
Join
(
"|"
,
names
.
ToArray
());
var
cache
=
CachedOutputSetters
<
T
>.
Cache
;
Action
<
object
,
DynamicParameters
>
setter
=
(
Action
<
object
,
DynamicParameters
>)
cache
[
lookup
];
var
setter
=
(
Action
<
object
,
DynamicParameters
>)
cache
[
lookup
];
if
(
setter
!=
null
)
goto
MAKECALLBACK
;
// Come on let's build a method, let's build it, let's build it now!
...
...
Dapper/SqlMapper.cs
View file @
ad48bed2
...
...
@@ -884,7 +884,7 @@ private static T QueryFirstOrDefaultImpl<T>(this IDbConnection cnn, ref CommandD
this
IDbConnection
cnn
,
string
sql
,
Func
<
TFirst
,
TSecond
,
TReturn
>
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
,
CommandType
?
commandType
=
null
)
{
return
MultiMap
<
TFirst
,
TSecond
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
as
object
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
return
MultiMap
<
TFirst
,
TSecond
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
}
/// <summary>
...
...
@@ -908,7 +908,7 @@ private static T QueryFirstOrDefaultImpl<T>(this IDbConnection cnn, ref CommandD
this
IDbConnection
cnn
,
string
sql
,
Func
<
TFirst
,
TSecond
,
TThird
,
TReturn
>
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
,
CommandType
?
commandType
=
null
)
{
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
as
object
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
}
/// <summary>
...
...
@@ -933,7 +933,7 @@ private static T QueryFirstOrDefaultImpl<T>(this IDbConnection cnn, ref CommandD
this
IDbConnection
cnn
,
string
sql
,
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TReturn
>
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
,
CommandType
?
commandType
=
null
)
{
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
as
object
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
}
/// <summary>
...
...
@@ -959,7 +959,7 @@ private static T QueryFirstOrDefaultImpl<T>(this IDbConnection cnn, ref CommandD
this
IDbConnection
cnn
,
string
sql
,
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TReturn
>
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
,
CommandType
?
commandType
=
null
)
{
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
as
object
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
DontMap
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
}
/// <summary>
...
...
@@ -986,7 +986,7 @@ private static T QueryFirstOrDefaultImpl<T>(this IDbConnection cnn, ref CommandD
this
IDbConnection
cnn
,
string
sql
,
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TReturn
>
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
,
CommandType
?
commandType
=
null
)
{
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
as
object
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
DontMap
,
TReturn
>(
cnn
,
sql
,
map
,
param
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
}
...
...
@@ -1013,7 +1013,7 @@ private static T QueryFirstOrDefaultImpl<T>(this IDbConnection cnn, ref CommandD
/// <returns></returns>
public
static
IEnumerable
<
TReturn
>
Query
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>(
this
IDbConnection
cnn
,
string
sql
,
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>
map
,
object
param
=
null
,
IDbTransaction
transaction
=
null
,
bool
buffered
=
true
,
string
splitOn
=
"Id"
,
int
?
commandTimeout
=
null
,
CommandType
?
commandType
=
null
)
{
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>(
cnn
,
sql
,
map
,
param
as
object
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
return
MultiMap
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>(
cnn
,
sql
,
map
,
param
,
transaction
,
buffered
,
splitOn
,
commandTimeout
,
commandType
);
}
/// <summary>
...
...
@@ -1066,12 +1066,12 @@ public static IEnumerable<TReturn> Query<TReturn>(this IDbConnection cnn, string
reader
=
ownedReader
;
}
DeserializerState
deserializer
=
default
(
DeserializerState
);
Func
<
IDataReader
,
object
>[]
otherDeserializers
=
null
;
Func
<
IDataReader
,
object
>[]
otherDeserializers
;
int
hash
=
GetColumnHash
(
reader
);
if
((
deserializer
=
cinfo
.
Deserializer
).
Func
==
null
||
(
otherDeserializers
=
cinfo
.
OtherDeserializers
)
==
null
||
hash
!=
deserializer
.
Hash
)
{
var
deserializers
=
GenerateDeserializers
(
new
Type
[]
{
typeof
(
TFirst
),
typeof
(
TSecond
),
typeof
(
TThird
),
typeof
(
TFourth
),
typeof
(
TFifth
),
typeof
(
TSixth
),
typeof
(
TSeventh
)
},
splitOn
,
reader
);
var
deserializers
=
GenerateDeserializers
(
new
[]
{
typeof
(
TFirst
),
typeof
(
TSecond
),
typeof
(
TThird
),
typeof
(
TFourth
),
typeof
(
TFifth
),
typeof
(
TSixth
),
typeof
(
TSeventh
)
},
splitOn
,
reader
);
deserializer
=
cinfo
.
Deserializer
=
new
DeserializerState
(
hash
,
deserializers
[
0
]);
otherDeserializers
=
cinfo
.
OtherDeserializers
=
deserializers
.
Skip
(
1
).
ToArray
();
if
(
command
.
AddToCache
)
SetQueryCache
(
identity
,
cinfo
);
...
...
@@ -1133,7 +1133,7 @@ static IEnumerable<TReturn> MultiMapImpl<TReturn>(this IDbConnection cnn, Comman
ownedReader
=
ownedCommand
.
ExecuteReader
(
GetBehavior
(
wasClosed
,
CommandBehavior
.
SequentialAccess
|
CommandBehavior
.
SingleResult
));
reader
=
ownedReader
;
}
DeserializerState
deserializer
=
default
(
DeserializerState
)
;
DeserializerState
deserializer
;
Func
<
IDataReader
,
object
>[]
otherDeserializers
;
int
hash
=
GetColumnHash
(
reader
);
...
...
@@ -1350,7 +1350,6 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
if
((
identity
.
commandType
==
null
||
identity
.
commandType
==
CommandType
.
Text
)
&&
ShouldPassByPosition
(
identity
.
sql
))
{
var
tail
=
reader
;
var
sql
=
identity
.
sql
;
reader
=
(
cmd
,
obj
)
=>
{
tail
(
cmd
,
obj
);
...
...
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