I need the most efficient way to get the value of the searchName, or if null return searchName. I am returning just a single string, so maybe I should search itemRepository.Item instead of Items
return itemRepository.Items()
.Where(i => i.Name.Contains(searchName))
.Select(i => i.Value)
.FirstOrDefault() ?? searchName;
Itemsa method rather than a property (as evidenced by the())? Other than that question, this seems exactly the canonical way I'd do what you're looking for. \$\endgroup\$Valueof those that containsearchNamein itsName. \$\endgroup\$.Select()and the.FirstOrDefault(), but other than that, there's nothing else you can do to this query. \$\endgroup\$