Search code examples
asp.netsql-serverentity-frameworkentitydatasource

Using ISNULL function in EntityDataSource CommandText


I wrote below query in EntityDataSource CommandText.

SELECT FIRST_NAME + ' ' + ISNULL(LAST_NAME, '') AS Customer
FROM CUSTOMER

but there is an error as isnull cannot be resolved into valid type or function.

how cold i solve this ? what should i use instead of ISNULL ?


Solution

  • There is no support for ISNULL in entity sql. You'll have to resort to CASE WHEN:

    CASE
        WHEN LAST_NAME IS NULL THEN '' 
        ELSE LAST_NAME 
    END
    

    Can't help it.