Commit 5abf74fb authored by Marc Gravell's avatar Marc Gravell

Merge pull request #179 from matwilko/idictionary-fix

Allow passing an IDictionary<string, object> as parameter object
parents dc17868d d2cce62d
...@@ -2048,9 +2048,12 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter ...@@ -2048,9 +2048,12 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
{ {
info.ParamReader = (cmd, obj) => { ((IDynamicParameters)obj).AddParameters(cmd, identity); }; info.ParamReader = (cmd, obj) => { ((IDynamicParameters)obj).AddParameters(cmd, identity); };
} }
#if !CSHARP30 #if CSHARP30
// special-case dictionary && `dynamic` else if (exampleParameters is IEnumerable<KeyValuePair<string, object>>)
else if (exampleParameters is IEnumerable<KeyValuePair<string, object>> && exampleParameters is System.Dynamic.IDynamicMetaObjectProvider) #else
// special-case dictionary and `dynamic`
else if (exampleParameters is IEnumerable<KeyValuePair<string, object>> || exampleParameters is System.Dynamic.IDynamicMetaObjectProvider)
#endif
{ {
info.ParamReader = (cmd, obj) => info.ParamReader = (cmd, obj) =>
{ {
...@@ -2058,7 +2061,6 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter ...@@ -2058,7 +2061,6 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
mapped.AddParameters(cmd, identity); mapped.AddParameters(cmd, identity);
}; };
} }
#endif
else else
{ {
var literals = GetLiteralTokens(identity.sql); var literals = GetLiteralTokens(identity.sql);
......
...@@ -3842,6 +3842,15 @@ public void SO25297173_DynamicIn() ...@@ -3842,6 +3842,15 @@ public void SO25297173_DynamicIn()
result.Contains(6).IsTrue(); result.Contains(6).IsTrue();
} }
public void AllowIDictionaryParameters()
{
var parameters = new Dictionary<string, object>
{
{ "param1", 0 }
};
connection.Query("SELECT @param1", parameters);
}
#if POSTGRESQL #if POSTGRESQL
class Cat class Cat
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment