-
Notifications
You must be signed in to change notification settings - Fork 933
Support setting parameters with a dynamic object #2320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support setting parameters with a dynamic object #2320
Conversation
3017c72
to
097aad5
Compare
@@ -651,6 +651,8 @@ public IQuery SetEnum(string name, Enum val) | |||
return this; | |||
} | |||
|
|||
// Since 5.3 | |||
[Obsolete("This method was never surfaced to a query interface. Use the overload or extension method taking a generic dictionary instead.")] | |||
public IQuery SetProperties(IDictionary map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have considered adding an extension method for it too, but this was causing an ambiguous method call when using a Dictionary<string, object>
, since it does implement both IDictionary
and IDictionary<string, object>
. So it looks to me not worth keeping this method.
/// </summary> | ||
/// <param name="query">The query on which to set the parameters.</param> | ||
/// <param name="map">A dictionary of parameters values by names.</param> | ||
public static IQuery SetParameters(this IQuery query, IDictionary<string, object> map) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to change the name, since non extension methods takes precedence. Moreover the name SetProperties
does not make much sense in my view, this one is more semantically accurate I think.
So I have added a commit to obsolete SetProperties
in favor of a SetParameters
overload.
} | ||
|
||
// Since 5.3 | ||
[Obsolete("Use SetParameters method instead.")] | ||
public IQuery SetProperties(object bean) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if we use this method to support the IDictionary<string, object>
?
public IQuery SetProperties(object bean) | |
public IQuery SetProperties(object bean) | |
{ | |
if (bean is IDictionary<string, object> map) | |
{ | |
// TODO: | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be less discoverable, but it would support dynamic
without having to do an explicit static call on some extension class.
Fixes #2009