Linq and Lambda syntax

var jsonData = from user in users
               select new[] { user.Id.ToString(),
                              user.Person.Lastname,
                              user.Person.Firstname };
Alternatively, you can use the lambda syntax:
var jsonData = users.Select(user => new[] { user.Id.ToString(),
                                            user.Person.Lastname,
                                            user.Person.Firstname });

Comments

Popular posts from this blog

Linq Exclude from separate list

Sorting Ascending and Descending

Linq Query Syntax vs Method Syntax