I did try to search the forums and documentation, so apologies if I missed it.
I am trying to determine if the driver would automatically project(mongo use of the word) an object automatically depending on what I ask the driver for from a C# object perspective or if I need to specifically project.
I am specifically asking in terms of how this would relate to network traffic.
Code below is not exact(writing it in the post) but the concept is there
Example:
public class Pet
{
string Name;
int Age;
}
public class Dog : Pet
{
string Breed;
}
//here i am working with the collection of Pets and I am asking for a "Pet" object, which only has 2 properties. It does not have the breed property. If the object I am getting has the breed property is that property returned from Mongo and then ignored/removed at the driver level, or it is blocked from being returned, as it would with a project
var coll = DB.GetCollection<Pets>("Pets");
coll.Find<Pet>(x => x.Name == "Bob").FirstOrDefault();
VS
var simpleProjection = Builders<Pet>.Projection
.Include(u => u.Name)
.Include(u => u.Age);
var coll = DB.GetCollection<Pet>("Pets");
coll.Aggregate()
.Match(x => x.Name == "Bob")
.Project(simpleProjection )
.ToList()
I am not sure how to figure out or measure what data actually comes over the network(from mongo atlas to my local machine) and what data is just filtered out after the return vs. filtered out server-side
Primary Goal/Reason for Question: Attempting to reduce ingress and egress of the data coming out of Mongo as we don’t always need all properties.
We have been doing it via the C# casting method, but I have no idea how to measure the network traffic on this.