Skip to content

Instantly share code, notes, and snippets.

@darrencauthon
Created November 11, 2010 12:43
Show Gist options
  • Save darrencauthon/672429 to your computer and use it in GitHub Desktop.
Save darrencauthon/672429 to your computer and use it in GitHub Desktop.
Returning an anonymous type as a dynamic to retrieve the values elsewhere
public class IdRetriever {
private IEnumerable<Person> people;
public IdRetriever(IEnumerable<Person> people){
this.people = people;
}
public IEnumerable<int> GetIds(){
return GetTheIds()
.Select(x=>(int)x.Id);
}
private IEnumerable<dynamic> GetTheIds(){
return people.Select(x=>new {Id = x.Id});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment