public class Foo
{
public int Id { get; set; }
public int UserId { get; set; }
}
这似乎是异步执行此操作的方法:
DatabaseContext db = new DatabaseContext();
Foo foo = await db.Foos.FindAsync(fooid);
如何根据 UserId 的值异步获取特定用户的所有 Foos?
最佳答案
假设您使用的是 Entity Framework 6.0(预发行版):
var userId = ...;
var foos = await db.Foos.Where(x => x.UserId == userId).ToListAsync();
关于c# - 具有非主键值的 FindAsync,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18964488/