2015-02-07 80 views
1

我在标题中出现错误。无法将类型'Task <System.Collections.Generic.IEnumerable <IClass>>'隐式转换为'System.Collections.Generic.IEnumerable <IClass>

我的资料库的方法是:

public async Task<IEnumerable<IItem>> GetItemsAsync() 
{ 
    return await (from t in _Context.Items 
    select t).ToListAsync(); 
} 

我与调用它:

data.Items = _FSRepository.GetItemsAsync(); 

data.Items声明为:

public IEnumerable<IItem> Items { get; set; } 

这是为什么不转换任务IEnumerable接口IEnumerable接口?

回答

5

你必须awaitGetItemsAsync否则它返回方法的签名。 await解开Task

+0

哇,这是我的失败。我不敢相信我跳过那个。 – ScubaSteve 2015-02-07 02:30:38

相关问题