Hi All! I am a MongoDB DBA supporting C# .NET developers. We are having issues with an aggregation query in that it is not coming through in the way we want it from C#. When I write it out in JSON using Studio 3T, it comes back in < 1 second and returns the expected number of documents (~16,000). When my DEV tries to do it in the MongoDB C# driver it takes over 3 minutes and returns over 360,000 docs. What is coming from the driver is not structured correctly. Here is the proper query:
db = db.getSiblingDB("Benefits");
db.getCollection("BenefitSummariesQuoting").aggregate(
[
{
$match: {
"EffectiveDate" : { "$lte" : ISODate("2021-11-01T04:00:00.000+0000") },
"$or" : [
{
"EndDate" : null
},
{
"EndDate" : { "$gte" : ISODate("2021-11-01T04:00:00.000+0000") }
}
],
"$or" : [
{
"State" : "MD"
},
{
"State" : "M"
}
]
}
},
{ $project: {
"CarrierPlanId" : 1.0,
"HsaEligible" : 1.0,
"PCPRequired" : 1.0,
"PlanType" : 1.0,
"ReferralRequired" : 1.0,
"ProductKey" : 1.0,
"CarrierId" : 1.0,
"BenefitSpecifications.Benefit.Name" : 1.0,
"BenefitSpecifications.Coverage.OriginalDescription" : 1.0,
"BenefitSpecifications.CoverageTier2.OriginalDescription" : 1.0
}
},
{
$sort: {
"EffectiveDate" : -1.0,
"DateInserted" : -1.0
}
},
],
{
allowDiskUse: true
}
);
Does anyone have any hints or guidance for how that should be represented in C#?
Thanks!
Bill