我有以下 lambda 表达式:
string queryToken = queryTokens.Last();
var result = from locationAddress in locations
let tokens = GetLetterTokens(locationAddress.Name)
let distance = (from token in tokens
where token.Contains(queryToken, StringComparison.OrdinalIgnoreCase)
select token.Length - queryToken.Length).Min()
orderby distance
select new
{
LocationAddress = locationAddress,
LocationDistance = distance,
};
不管它是为了什么而写的。有时计数时distance
,没有tokens
包含queryToken
,所以.Min()
无法返回。如何跳过这些情况?我不想将它们添加到result
变量中。