简体   繁体   English

具有非主键值的FindAsync

[英]FindAsync with non-primary key value

public class Foo
{
     public int Id { get; set; }
     public int UserId { get; set; }
}

This appears to be the way to do this asynchronously: 这似乎是异步执行此操作的方法:

DatabaseContext db = new DatabaseContext();
Foo foo = await db.Foos.FindAsync(fooid);

How does one asynchronously get all of the Foos for a specific user based on UserId's value? 如何根据UserId的值异步获取特定用户的所有Foos?

Assuming you are using Entity Framework 6.0 (prerelease): 假设您正在使用Entity Framework 6.0(预发行版):

var userId = ...;
var foos = await db.Foos.Where(x => x.UserId == userId).ToListAsync();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM