FindByIdAsync函数在最后一行返回值时显示错误

时间:2015-07-22 10:42:02

标签: entity-framework-6

public Task<TUser> 
 FindMainUserByIdAsync(string id){
  var user =_context.Users.Where(x => x.Id.Equals(id)).SingleOrDefaultAsync();
  return Task.Run(() => user);
}

1 个答案:

答案 0 :(得分:0)

公共异步任务  FindMainUserByIdAsync(string id){  var user = await _context.Users.Where(x =&gt; x.Id.Equals(id))。SingleOrDefaultAsync();  将用户返回为TUser;  }