hi, i have wrote a method that filters output with provided query and return it. when one Where excuted; it return correct output but when more than one Where excuted; output is null and Exception occured with message "Enumeration yielded no results". why? how i can fix it?
public IQueryable<SearchResult> PerformSearch(string query, int skip = 0, int take = 5)
{
if (!string.IsNullOrEmpty(query))
{
var queryList = query.Split('+').ToList();
var results = GENERATERESULTS();
string key;
foreach (string _q in queryList)
{
if (_q.StartsWith("(") && _q.EndsWith(")"))
{
key = _q.Replace("(", "").Replace(")", "");
results = results.Where(q => q.Title.Contains(key, StringComparison.CurrentCultureIgnoreCase));
}
else if (_q.StartsWith("\"") && _q.EndsWith("\""))
{
key = _q.Replace("\"", "").Replace("\"", "");
results = results.Where(q => q.Title.Contains(key, StringComparison.CurrentCulture));
}
else if (_q.StartsWith("-(") && _q.EndsWith(")"))
{
key = _q.Replace("-(", "").Replace(")", "");
results = results.Where(q=> !q.Title.Contains(key, StringComparison.CurrentCultureIgnoreCase));
}
else
{
key = _q;
results = results.Where(q => q.Title.Contains(key, StringComparison.CurrentCulture));
}
}
this._Count = results.Count();
results = results.Skip(skip).Take(take);
this._EndOn = DateTime.Now;
this.ExecutionTime();
return results;
}
else return null;
}
thanks in advance ;)