I have got a class called Contact which has a field named Numbers and Numbers is a list of strings. I want to return a list containing all numbers in matched documents only. but it gives me an array of BsonDocuments. I need Just a List of numbers.
here is my query:
var query = await _context.ContactLists.Aggregate(new AggregateOptions { AllowDiskUse = true })
.Match(x => x.Id == id && x.CreatorId == user.GetUserId())
.Unwind(x => x.Numbers)
.Project(Builders<BsonDocument>.Projection.Include("Numbers").Exclude("_id"))
.ToListAsync();
it resturns :
[{{ "Numbers" : "989309910790" }}]
and I need :
["989309910790"]
I am not allowed to use Linq driver.