I was in a hurry and didn't do a good job of explaining this. Also, I made a copy/paste error in the previous code example and that didn't help things.
Here's what I meant to post for the code example.
var qf = new QueryFactory();
var query = qf.Create()
.Select<CustomerModel>(CustomerFields.CompanyName.ToUpper(),
CustomerFields.City, CustomerFields.City)
.OrderBy(CustomerFields.CompanyName.Ascending());
Before I go any further, I'm going to define the term "DQE alias" to mean any alias that the DQE assigns (like "AS [LLBLV_1]") as opposed to one that I specifically assign.
Taking the above query as an example. There are two ambiguous parts to that query and the DQE doesn't treat them the same way. I think they should either behave the same way or else be opposite of the current behavior.
1) The City field is listed twice without an .As(). At runtime, the DQE will NOT give the second one a random column alias ("AS [LLBLV_1]"). Instead, it will throw an exception even though giving the second City field a DQE alias would be a more tolerant approach and would be unlikely to cause anything to fail.
2)The CompanyName.ToUpper() also does not have an .As(). At runtime, the DQE WILL assign the DQE alias. This is actually a less tolerant approach because my code will fail silently for things like model mapping.
I get your point that the DQE doesn't know what the function call does. However, the column needs an alias no matter what the function call returns. That is why you are having the DQE assign an alias ("AS [LLBLV_1]").
I'd prefer that since the DQE knows it has got to assign an alias, why can't it check to see if the original column name is in use already? If it is in use, either assign a DQE alias or throw an exception as it currently does when the same field is defined more than once without an alias.
Hoping that the third time is the charm for this thread.