Skip to content

Commit ad48bed

Browse files
committed
Cleanup
Remove some unused casts, variables, and warnings
1 parent e24c472 commit ad48bed

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

Dapper/DynamicParameters.CachedOutputSetters.cs

+4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ namespace Dapper
44
{
55
partial class DynamicParameters
66
{
7+
// The type here is used to differentiate the cache by type via generics
8+
// ReSharper disable once UnusedTypeParameter
79
internal static class CachedOutputSetters<T>
810
{
11+
// Intentional, abusing generics to get our cache splits
12+
// ReSharper disable once StaticMemberInGenericType
913
public static readonly Hashtable Cache = new Hashtable();
1014
}
1115
}

Dapper/DynamicParameters.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public DynamicParameters(object template)
6161
/// <param name="param"></param>
6262
public void AddDynamicParams(object param)
6363
{
64-
var obj = param as object;
64+
var obj = param;
6565
if (obj != null)
6666
{
6767
var subDynamic = obj as DynamicParameters;
@@ -394,7 +394,7 @@ public DynamicParameters Output<T>(T target, Expression<Func<T, object>> express
394394
var lookup = string.Join("|", names.ToArray());
395395

396396
var cache = CachedOutputSetters<T>.Cache;
397-
Action<object, DynamicParameters> setter = (Action<object, DynamicParameters>)cache[lookup];
397+
var setter = (Action<object, DynamicParameters>)cache[lookup];
398398
if (setter != null) goto MAKECALLBACK;
399399

400400
// Come on let's build a method, let's build it, let's build it now!

Dapper/SqlMapper.cs

+9-10
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TReturn>(
884884
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
885885
)
886886
{
887-
return MultiMap<TFirst, TSecond, DontMap, DontMap, DontMap, DontMap, DontMap, TReturn>(cnn, sql, map, param as object, transaction, buffered, splitOn, commandTimeout, commandType);
887+
return MultiMap<TFirst, TSecond, DontMap, DontMap, DontMap, DontMap, DontMap, TReturn>(cnn, sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
888888
}
889889

890890
/// <summary>
@@ -908,7 +908,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TReturn>(
908908
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
909909
)
910910
{
911-
return MultiMap<TFirst, TSecond, TThird, DontMap, DontMap, DontMap, DontMap, TReturn>(cnn, sql, map, param as object, transaction, buffered, splitOn, commandTimeout, commandType);
911+
return MultiMap<TFirst, TSecond, TThird, DontMap, DontMap, DontMap, DontMap, TReturn>(cnn, sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
912912
}
913913

914914
/// <summary>
@@ -933,7 +933,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TRetu
933933
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
934934
)
935935
{
936-
return MultiMap<TFirst, TSecond, TThird, TFourth, DontMap, DontMap, DontMap, TReturn>(cnn, sql, map, param as object, transaction, buffered, splitOn, commandTimeout, commandType);
936+
return MultiMap<TFirst, TSecond, TThird, TFourth, DontMap, DontMap, DontMap, TReturn>(cnn, sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
937937
}
938938

939939
/// <summary>
@@ -959,7 +959,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFift
959959
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
960960
)
961961
{
962-
return MultiMap<TFirst, TSecond, TThird, TFourth, TFifth, DontMap, DontMap, TReturn>(cnn, sql, map, param as object, transaction, buffered, splitOn, commandTimeout, commandType);
962+
return MultiMap<TFirst, TSecond, TThird, TFourth, TFifth, DontMap, DontMap, TReturn>(cnn, sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
963963
}
964964

965965
/// <summary>
@@ -986,7 +986,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFift
986986
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
987987
)
988988
{
989-
return MultiMap<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, DontMap, TReturn>(cnn, sql, map, param as object, transaction, buffered, splitOn, commandTimeout, commandType);
989+
return MultiMap<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, DontMap, TReturn>(cnn, sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
990990
}
991991

992992

@@ -1013,7 +1013,7 @@ public static IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFift
10131013
/// <returns></returns>
10141014
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)
10151015
{
1016-
return MultiMap<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(cnn, sql, map, param as object, transaction, buffered, splitOn, commandTimeout, commandType);
1016+
return MultiMap<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(cnn, sql, map, param, transaction, buffered, splitOn, commandTimeout, commandType);
10171017
}
10181018

10191019
/// <summary>
@@ -1066,12 +1066,12 @@ static IEnumerable<TReturn> MultiMapImpl<TFirst, TSecond, TThird, TFourth, TFift
10661066
reader = ownedReader;
10671067
}
10681068
DeserializerState deserializer = default(DeserializerState);
1069-
Func<IDataReader, object>[] otherDeserializers = null;
1069+
Func<IDataReader, object>[] otherDeserializers;
10701070

10711071
int hash = GetColumnHash(reader);
10721072
if ((deserializer = cinfo.Deserializer).Func == null || (otherDeserializers = cinfo.OtherDeserializers) == null || hash != deserializer.Hash)
10731073
{
1074-
var deserializers = GenerateDeserializers(new Type[] { typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh) }, splitOn, reader);
1074+
var deserializers = GenerateDeserializers(new [] { typeof(TFirst), typeof(TSecond), typeof(TThird), typeof(TFourth), typeof(TFifth), typeof(TSixth), typeof(TSeventh) }, splitOn, reader);
10751075
deserializer = cinfo.Deserializer = new DeserializerState(hash, deserializers[0]);
10761076
otherDeserializers = cinfo.OtherDeserializers = deserializers.Skip(1).ToArray();
10771077
if(command.AddToCache) SetQueryCache(identity, cinfo);
@@ -1133,7 +1133,7 @@ static IEnumerable<TReturn> MultiMapImpl<TReturn>(this IDbConnection cnn, Comman
11331133
ownedReader = ownedCommand.ExecuteReader(GetBehavior(wasClosed, CommandBehavior.SequentialAccess | CommandBehavior.SingleResult));
11341134
reader = ownedReader;
11351135
}
1136-
DeserializerState deserializer = default(DeserializerState);
1136+
DeserializerState deserializer;
11371137
Func<IDataReader, object>[] otherDeserializers;
11381138

11391139
int hash = GetColumnHash(reader);
@@ -1350,7 +1350,6 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
13501350
if((identity.commandType == null || identity.commandType == CommandType.Text) && ShouldPassByPosition(identity.sql))
13511351
{
13521352
var tail = reader;
1353-
var sql = identity.sql;
13541353
reader = (cmd, obj) =>
13551354
{
13561355
tail(cmd, obj);

0 commit comments

Comments
 (0)