Open ALMMa opened 2 years ago
Sorry for the delay. Could you provide more details, like which is the database so I could try to replicate?
Sorry for the delay.
Here's some tech details:
I have a page upon which I need to display a small subset of data, as well as a paging mechanism.
To be able to perform that, I first check all filters and everything, apply the count, then retrieve the paged data. And manually a ViewModel
object is composed in order to have these filled for the UI.
I just moved between countries so it took a while to come back. I'm already pushing apps from 5.0 to 6.0, will re-validate and if the issue persists, will send you detailed instructions on how to reproduce. If possible, I'll see if I can build a sample app that demonstrates this.
I can confirm this line is breaking subsequent Count operations. ClassMapper SimpleAlias is modified using Reflection. After this, every count on that table that doesn't have a Select to the same table before it, will break. If there is a Select to the same table before the Count it will work because table alias will be set to the same value as ClassMapper.SimpleAlias (this made the bug difficult to track because it may get you to think it happens randomly).
It does not make sense to me that the SQL Generator needs to modify the ClassMapper. But I can't fully understand the usefulness of the mentioned line.
Affected version:
1.7.0
(this works with1.6.3
).I'm able to demonstrate the issue, though I still don't fully get what's happening and why alias generation/mapping is not working anymore.
Consider the code (sligthly simplified):
This code is inside a
scoped
repository class and the response is used on the controller response to build the UI (Razor) including a paging mechanism. It's entirely on AspNet MVC Core (5.0
) and nothing should be stateful here.When I run this code for the first time I get a count query which is similar to:
However, on the second time we go to the same screen or if we refresh the page there, the cound SQL generated now looks like this:
As you can see, now all properties are prefixed with the automatic table alias (
y_1
) but not the table. This causes the notoriousmultipart identifier...
error.Somehow I managed to fix this by forcing a cleanup on the table mapping right before we start to build the count command here, as follows:
This seems to work at least on my case, but I can't guarantee it won't have side effects with others, mainly for more complex cases. Can you please advise on what I should look into, to better troubleshoot this?