No projection is passed to mongoDb at all and all fields are returned.
Hi Vadim,
I tried to reproduce this issue with both MongoDB .NET/C# v2.4.4 and also the current stable v2.7.3 without success.
Since you didn't provide the mapping for SubscriberStatus, I'm using the following mapping example:
public class SubscriberSource
|
{
|
public ObjectId Id { get; set; }
|
public DateTime? StatusChangeDate { get; set; }
|
public SubscriberStatus Status {get; set; }
|
public String Baz {get; set; }
|
}
|
public class SubscriberStatus
|
{
|
public String Foo {get; set; }
|
public int Bar {get; set;}
|
}
|
Using the following example:
var query = Builders<SubscriberSource>.Filter.Eq(x => x.Baz, "x");
|
var results = collection.Find(query).Project(x => new {x.StatusChangeDate, x.Status}).FirstOrDefault();
|
The result projects field StatusChangeDate and all fields nested under Status. You can also project only specific field(s) nested under Status by specifying it. The example below projecting field StatusChangeDate and only field Foo nested under Status:
var results = collection.Find(query).Project(x => new {x.StatusChangeDate, x.Status.Foo}).FirstOrDefault();
|
If you still have further question, could you please provide:
- Mapping definition of SubscriberStatus
- The output projected fields that you're getting
- The output projected fields that you're expecting to see (which field you don't want to be returned)
Regards,
Wan.
|