FindAsync with non-primary key value

邮差的信 提交于 2019-12-09 07:53:38

问题


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?


回答1:


Assuming you are using Entity Framework 6.0 (prerelease):

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


来源:https://stackoverflow.com/questions/18964488/findasync-with-non-primary-key-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!