MongoDB does not support predictions like SQL databases do; you can request a partial document, but you will still return something that matches the outline of the document you requested. In your case, you are returned only in the tasks field, and for each task - only the name field.
You can easily convert this to a list of strings using a simple LINQ:
var categoryTasks = Categories.Find<Category>(x => x.CategoryName == catName) .Project(Builders<Category>.Projection .Include("tasks.name") .Exclude("_id")) .ToListAsync() .Result; var taskNames = categoryTasks.Tasks.Select(task => task.Name).ToList();
Alternatively, you can do some fancy stuff with the aggregation API (which supports custom forecasts, curious ones), but this will probably be redundant for you.
Avish source share