2

I am able to query all the items of a collection using 2 approaches

a)

var findAll = await Context.ItemsCollection.FindAsync(_ => true);
var res = await findAll.ToListAsync();

b)

var res = await.Context.ItemsCollection.Find(_ => true).ToListAsync();

Is there a real difference between them?Which one should I prefer ?

i3arnon
  • 113,022
  • 33
  • 324
  • 344
g bas
  • 798
  • 1
  • 5
  • 18

1 Answers1

2

There's no real difference. It will eventually behave the same.

Find doesn't execute the query, while FindAsync does, but using ToListAsync makes that difference irrelevant.

i3arnon
  • 113,022
  • 33
  • 324
  • 344