In relation with this question about how to write long SQL queries within C#., the solution suggested that a long sql query should be written as:
string query = @"
SELECT
c.CUSTOMER_ID,
COALESCE (c.FIRST_NAME, ''_ + ' ' + COALESCE (c.LAST_NAME, '') AS FULL_NAME
ct.NAME as CUSTOMER_TYPE
FROM
CT_CUSTOMER_TYPE AS ct INNER JOIN CUSTOMER AS c
ON ct.CUSTOMER_TYPE_ID = c.CUSTOMER_TYPE_ID
";
That makes me curious about another related question. Can I use substitution somehow? That is, how would I manage if say the table name changes but the query remains the same? Do I have to fall back to using the other approach of building a string using string concatenations or is there a more elegant way?
Why not make use of string.Format? In the specific example you gave, you could do something like
And the invoke