Reputation: 4068
How do I return an object other than Task from an async method? I do some async work in the method, but I need to return something other than Task or return the object inside a Task. I don't know.
Code:
public async Task<ICollection<KeyValuePair<int, IServiceProvider>>> GetGroupedSearchStrings(int shopId)
{
ICollection<KeyValuePair<int, ISearchString>> result = new Collection<KeyValuePair<int, ISearchString>>();
IEnumerable<ISearchString> ss = await ShopsExpressions.SearchString(this.Worker.GetRepo<SearchString>().DbSet).Where(s => s.Active && s.ShopId.Equals(shopId)).OrderBy(s => s.DateCreated).ToListAsync();
result.Add(new KeyValuePair<int, ISearchString>(1, DEMO));
return result;
}
Upvotes: 1
Views: 511
Reputation: 3090
Async functions should be returning a Task.
You need to await
the Task when you call it.
var result = await GetGroupedSearchStrings(shopID);
Upvotes: 3