I would like to create a LINQ query which results in the following SQL statement. Let’s say I have a simple table with just two character fields – field1 and field2. My SQL statement would be:
SELECT field1, field2, field1+field2 AS ConcatField
FROM TableX
WHERE field1+field2 = 'abcdef'
How can this be done in LINQ?
You can use a
letclause for defining your concatfield and then select an anonymous type with the 3 fields you want to return.Regarding to your example of the more complex where clause,you would need to build an array of the values you want to compare to and then do something like this: