-
Notifications
You must be signed in to change notification settings - Fork 934
Fix querying with delayed entity insert #2416
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
Conversation
Log.Debug("binding 0 to parameter: {0}", index); | ||
} | ||
|
||
st.Parameters[index].Value = 0; |
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 assumes the identifier is compatible with an int
, and this assumes 0
is not a valid value for it. This will be wrong in many cases.
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.
DelayedPostInsertIdentifier exists only for auto-increment fields, so I believe that the value 0 in this case is correct
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 compared this behavior with entity framework core 3 comparison by reference for an entity that is not yet stored in the table returns exactly parameter 0 in all cases
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 entity.Id
is not 0 for transient entity and for instance it's -1?
DelayedPostInsertIdentifier exists only for auto-increment fields, so I believe that the value 0 in this case is correct
Not true for the following SQL Server table:
CREATE TABLE Entity
(
Id int IDENTITY(0,1), -- start from 0
Name varchar (20)
);
With changes from #3043 now tests fail. |
Fix #2414