Th variable query is of type IMongoQueryable interface. You can apply any of its methods to get the output of your choice. For example, the following will get a List and print its contents (the names of the persons).
var peopleList = query.ToList<string>();
peopleList.ForEach(s => Console.WriteLine(s));
Hey Thank you so much! That made things very clear for me!
I tried to apply this but when I code
var peopleList = query.ToList<string>();
I get the error:
Cannot resolve method ‘ToList()’, candidates are: System.Collections.Generic.List ToList(this MongoDB.Driver.IAsyncCursorSource, System.Threading.CancellationToken) (in class IAsyncCursorSourceExtensions) System.Collections.Generic.List ToList(this System.Collections.Generic.IEnumerable) (in class Enumerable)
so instead I coded this:
> var peopleList = query.ToList<string>(CancellationToken.None);
however this time I got this error:
Cannot convert instance argument type ‘{MongoDB.Driver.Linq.IMongoQueryable,System.Collections.Generic.IEnumerable,System.Linq.IQueryable}’ to ‘MongoDB.Driver.IAsyncCursorSource’
So do you know how I can solve this? Frankly I would like to find out how to map the peopleList to something like
var peopleList = query.ToList<personDTO>(CancellationToken.None);