I swear I've run into this problem before, and don't remember how I solved it.
I need to include Full Name in the select list of a dynamic list query as an Expression from Person.FirstName + " " + Person.LastName. I then need to group by this column as well.
The query emits:
([cat].[dbo].[Person].[FirstName] + @LLBLEP1) + [cat].[dbo].[Person].[LastName] AS [FullName],
in the select list, and
([cat].[dbo].[Person].[FirstName] + @LLBLEP6) + [cat].[dbo].[Person].[LastName],
in the group by clause. This fails because the parameters are different even though the value is the same.
This is how I create the field:
var firstNameExp = new Expression(PersonFields.FirstName, ExOp.Add, " ");
var fullNameExp = new Expression(firstNameExp, ExOp.Add, PersonFields.LastName);
new EntityField2(FULL_NAME_FIELD_NAME, fullNameExp)
I have also tried:
new EntityField2(FULL_NAME_FIELD_NAME, (PersonFields.FirstName + " " + PersonFields.LastName))
How can I get the literal (" ") to be reused as a single parameter in the query, or have the full expression be reused? Do I need to use a DBFunctionCall?
Thanks,
Phil
Using version 2.6.9.305 vs. SQL Server 2008.