LINQ to SQL column has keyword as column name, how to quote / exit

In the LINQ to SQL statement, I have the column name in the database, also the C # keyword (void). How to make the compiler consider this as a property of an object, not a keyword?

I could rewrite this using method notation, of course, but there should be a way to give the compiler a hint here ...

var p = from c in mytable
        where c.id = rowNumber
        select ( new { voidedState = c.void } );  // <--- Problem is here

Mistake:

Identifier expected; 'void' is a keyword

I can't argue with that, I'm just looking for a workaround.

Thanks.

+5
source share
1 answer

Precede the identifier with "@":

@void

Is the identifier name "void" and not a keyword (this works wherever the identifier is required).

+20

All Articles