Skip to content

Instantly share code, notes, and snippets.

@csharpforevermore
Created September 13, 2018 14:21
Show Gist options
  • Save csharpforevermore/7a37b0edc7c80e364f7d47929aa1a839 to your computer and use it in GitHub Desktop.
Save csharpforevermore/7a37b0edc7c80e364f7d47929aa1a839 to your computer and use it in GitHub Desktop.
Using Linq, get all item Titles from a list by their IDs that existing in another List<int>
var idsOnly = new List<int>();
var myList = db.Items.Where(item => idsOnly.Contains(item.ID.Value))
.Select(a => a.Title).ToList();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment