Iulian
Iulian

Reputation: 1200

Linq To Sql: writing a query for a column named with two words

I'm trying to make query in a table that has a column named "First Name"

dim info = from md in employees _
where md!first name = "test" 

How can I use the field "first name" in this query.

I've tried \"first name\" and ""first name"" but neither works.

Upvotes: 0

Views: 667

Answers (2)

cllpse
cllpse

Reputation: 21727

Take a look at the class generated for your table. See if you can find the name of the field inside of it.

Methods, variables, properties, etc. can't contain spaces. Either the field has been left out of the class that's generated to represent your database table, or spaces has been stripped.

On a side-note; you might want to re-consider using spaces in column-names--using spaces and reserved key words are not very good practice.

Upvotes: 0

tvanfosson
tvanfosson

Reputation: 532465

Identifiers can't contain spaces in VB. The designer, I think, removes the spaces from the name when creating the entity class so it would simply be FirstName.

Upvotes: 3

Related Questions