If you are looking for only one Id once, there is no more efficient way.
If you are looking for identifiers several times, you can create a HashSet:
var activityIdsQuery = from a in ActivityList select a.Id; HashSet<Guid> activityIds = new HashSet<Guid>(activityIdsQuery);
If you need to find an instance of activity, you can create a dictionary (only works if Id is unique):
Dictionary<Guid, Activity> activities = ActivityList.ToDictionary(a => a.Id);
Another solution using Linq with Where / FirstOrDefault / Any on Id will not be more efficient than yours.
source share