I'm trying to return a new column that is the concatenation of id
and name
, with a hyphen inbeween, using dynamic-linq:
query.Select("new(id, name, id & " - " & name As idName")
But, I'm failing even to get simple concatenation working, even without the hyphen:
query.Select("new(id, name, id & name As idName")
This raises System.NotSupportedException
LINQ to Entities does not recognize the method System.String Concat(System.Object, System.Object) method, and this method cannot be translated into a store expression.
Is there any way around this, and if so, how would I also add the quoted section " - "
to the expression in a way that dynamic-linq can interpret, also I'd like id
and name
to be variables as these change depending on the user's selection?
NOTE:
- I'm using dynamic-linq because the names of the columns I want to concatenate vary, based on user selection, plus I'm already using dynamic-linq for a
Where
clause). - The
id
andname
columns are both of type string