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?
FindAsync(CancellationToken, Object[]) Asynchronously finds an entity with the given primary key values. If an entity with the given primary key values exists in the context, then it is returned immediately without making a request to the store.
The Find method takes an array of objects as an argument. When working with composite primary keys, pass the key values separated by commas and in the same order that they are defined in the model.
Assuming you are using Entity Framework 6.0 (prerelease):
var userId = ...; var foos = await db.Foos.Where(x => x.UserId == userId).ToListAsync();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With