I would like to improve the performance of the following LINQ statement to ensure that it's getting back the list as efficiently as possible.
I am receiving the following warning on the server: The LINQ expression 'where [s].Building.Contains(__searchString_0, CurrentCulture)' could not be translated and will be evaluated locally.
string searchString = siteCode + " " + building + " ";
var floorLocations = _applicationDbContext.CurrentLocations
.Where(s => s.Building.Contains(searchString, StringComparison.CurrentCulture)).OrderBy(x => x.Building)
.Select(s => s.Building.Split('-', StringSplitOptions.None)[0]).Distinct().ToList();
Overall I want to ensure that this LINQ statement is optimized as it will be called multiple times per minute at peak usage throughout the day.