-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query: Allow FromSql to accept parameter of type DbParameter in subquery #8885
Conversation
51b6ff3
to
8168cec
Compare
if (parameterValues.TryGetValue(parameter.InvariantName, out var parameterValue)) | ||
if (parameter is RawRelationalParameter) | ||
{ | ||
parameter.AddDbParameter(command, value: null); |
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.
Since IRelationalParameter.AddDbParameter` has value parameter, passing null in this case.
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.
Change to polymorphic call on parameter
|
||
substitutions = new string[argumentValues.Length]; | ||
|
||
for (var i = 0; i < argumentValues.Length; i++) | ||
{ | ||
var value = argumentValues[i]; | ||
if (value is DbParameter dbParameter) | ||
{ | ||
substitutions[i] = dbParameter.ParameterName; |
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.
So this is to support {0} syntax with raw parameter?
{ | ||
substitutions[i] = dbParameter.ParameterName; | ||
_relationalCommandBuilder.AddRawParameter(dbParameter.ParameterName, dbParameter); | ||
continue; |
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.
Just use else instead?
f7a4e48
to
0bb07a9
Compare
@anpete - Ready for review Test patterns covered
cc: @divega - If you want to check out. |
0bb07a9
to
779da18
Compare
/// </summary> | ||
public void AddDbParameter(DbCommand command, object value) | ||
{ | ||
if (value == null) |
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.
This ever false?
65f366e
to
78fceb9
Compare
Add RawRelationalParameter to flow user defined DbParameter to DbCommand Add method on IRelationalParameter which takes command and parameterValues Add RelationalParameterBase class FromSql when taking DbParameter arg - Use format item to substitute if available - Use named arg if no format item available - Generate a name if DbParameter.ParameterName is unspecified
78fceb9
to
4c94662
Compare
Updated. |
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.
Nice!
Resolves #8721
TODO:
@anpete - Creating PR to get initial feedback on the approach.