Posted By

housecor on 10/27/10


Tagged


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

Tyster
danfinrud55


Naming a projected anonymous type in LINQ


 / Published in: C#
 

Note that C# doesn't allow naming in the SELECT statement. Must use the LET operator for this purpose.

  1. from c in context.Contacts
  2. where c.FirstName == "Robert"
  3. let ContactName = new {c.Title, c.LastName, c.FirstName}
  4. select ContactName

Report this snippet  

You need to login to post a comment.