我有这个方法:
/// <summary>
/// Gets the query filter.
/// </summary>
/// <param name="queryText">The query text.</param>
/// <returns>The query filter predicate.</returns>
private Task<Predicate<int>> GetQueryFilter(string queryText)
{
// Return the query filter predicate
return new Predicate<int>(async(id) =>
{
// Get the employee
StructuredEmployee employee = await LoadEmployee(id);
// If employee not found - return false
if (employee == null)
return false;
// Else if employee is found
else
// Check subject and body
return (!string.IsNullOrWhiteSpace(employee.FirstName)) && employee.FirstName.Contains(queryText)
|| (!string.IsNullOrWhiteSpace(employee.MiddleName)) && employee.MiddleName.Contains(queryText)
|| (!string.IsNullOrWhiteSpace(employee.LastName)) && employee.LastName.Contains(queryText);
});
}
我希望这个方法异步返回,即Task<Predicate<int>>
. 我该怎么做呢?目前我在async(id)
.