-
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
Named parameters (parameter placeholders) and Parameter vs PropertyParameter #14644
Comments
#14645 is related in that it also can't easily be fixed without looking at the Name. |
@AndriySvyryd @smitpatel @roji to look at this as part of 3.0 query (but also impacts update pipeline) @MaxG117 Which database provider are you working on? |
@MaxG117 - Can you tell where is |
@ajcvickers We haven't publicly announced yet, so I'm not at liberty to disclose at this time. @smitpatel apologies, I meant parameterValues.Keys, not propertyValues.Keys. |
Thanks for additional info. I can see why those keys being mismatched. In 3.0 pipeline I will see any other way to improve what you want to achieve but it is likely to be on the lines of doing something with PropertyParameter rather than RelationalCommand. @AndriySvyryd - Can you comment if modifying RelationalCommand as mentioned in first post is a good way to go or there is a better way to achieve this (w.r.t. Update pipeline). |
It would also be possible to override |
Entity equality introduces member access expressions on what may be a parameter or a constant. Identify these cases and generate a new parameter (for access of a parameter) or evaluate the constant. Fixes dotnet#15855 Fixes dotnet#14645 Fixes dotnet#14644
Note: moved this to the 3.0.0 milestone. |
Our data store does not support named parameters (a.k.a. parameter placeholders) -- we use question marks ("?") instead in
DbCommand.CommandText
, and we expect theDbCommand.Parameters
collection to contain all the parameters in order.This presents some challenges for implementing an EntityFrameworkCore provider. First we had to allow for duplicate parameters via #12347. Second, it looks like
CommandText
is generated independently in multiple places (DefaultQuerySqlGenerator
,UpdateSqlGenerator
), so the best place I found where I can rearrange command parameters and update command text is by overriding theRelationalCommand.CreateCommand
method.Does this make sense, or is there a better way to solve this?
Assuming that the above makes sense, consider the SimpleQueryTestBase.Where_poco_closure() test case:
It's the only test case that fails when using my
CreateCommand
override method. It fails because I assumed that parameterValues.Keys can be easily matched up with parameter placeholders, but this is not true forPropertyParameter
s. In the example above, the Key is "__customer_0", while the placeholder is "__customer_0_CustomerId".I'd rather not go through each TypeMappedRelationalParameter to look at its Name, but I can't think of another way to do it. And I suspect there may be other parameter types with the same problem. Is there an easier solution to this?
The text was updated successfully, but these errors were encountered: