Skip to content

Commit

Permalink
Fixes #152
Browse files Browse the repository at this point in the history
Allows use of IDictionary<string, object> as parameter objects.
I'm assuming that the && was a mistake, and that this logic should
handle both of the types equally well.
Also allows .NET 3.5 to use the IDictionary case.
  • Loading branch information
matwilko committed Sep 22, 2014
1 parent 5f1a30e commit d2cce62
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Dapper NET40/SqlMapper.cs
Expand Up @@ -2048,17 +2048,19 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
{
info.ParamReader = (cmd, obj) => { ((IDynamicParameters)obj).AddParameters(cmd, identity); };
}
#if !CSHARP30
// special-case dictionary && `dynamic`
else if (exampleParameters is IEnumerable<KeyValuePair<string, object>> && exampleParameters is System.Dynamic.IDynamicMetaObjectProvider)
#if CSHARP30
else if (exampleParameters is IEnumerable<KeyValuePair<string, object>>)
#else
// special-case dictionary and `dynamic`
else if (exampleParameters is IEnumerable<KeyValuePair<string, object>> || exampleParameters is System.Dynamic.IDynamicMetaObjectProvider)
#endif
{
info.ParamReader = (cmd, obj) =>
{
IDynamicParameters mapped = new DynamicParameters(obj);
mapped.AddParameters(cmd, identity);
};
}
#endif
else
{
var literals = GetLiteralTokens(identity.sql);
Expand Down

0 comments on commit d2cce62

Please sign in to comment.