web dunia
web dunia

Reputation: 9939

LINQ Named parameters with spaces

from c in Query
select new {User Name = c.UserName};

In LINQ I want to give the named arguments like this but it is not accepting User Name instead accepting UserName.

Upvotes: 0

Views: 255

Answers (1)

Jon Skeet
Jon Skeet

Reputation: 1502626

No, it won't - that's not a valid C# identifier. You can't do that.

Don't try to make the presentation names the same as identifiers. You should use some translation layer to go from property names to labels for the UI, etc.

Upvotes: 5

Related Questions