I have been trying to get a search working in C# for a Company Incident report. My code is:
var prj = new BsonDocument("$addFields",
new BsonDocument("result",
new BsonDocument("$strcasecmp",
new BsonArray(new[] {"$EmployeeFullName", $"{model.ConditionOne}"}))));
varmatchBson = new BsonDocument("$match",
new BsonDocument("result", 1));
var pipeline = PipelineDefinition<IncidentDashboardEntry, IncidentDashboardEntry>.Create(.Create(new BsonDocument[] {prj, matchBson});
var result = MongoHSESingleton<IncidentDashboardEntry>.GetIncidentReportInstance()
.Aggregate(pipeline)
.ToList();
which returns no results.
IncidentDashboardEntry is defined as:
public class IncidentDashboardEntry
{
public ObjectId _id { get; set; }
public int IncidentId { get; set; }
public string IncidentType { get; set; }
public DateTime DateOfIncident { get; set; }
public string DivisionProfitCenter { get; set; }
public string ReferenceNumber { get; set; }
public string EmployeeFullName { get; set; }
public string EmployeeName => $"{EmployeeLastName}, {EmployeeFirstName}";
public string EmployeeLastName { get; set; }
public string EmployeeFirstName { get; set; }
public string DayOfWeek => DateOfIncident.DayOfWeek.ToString();
}
I know i can reach the database because:
Atlas gives me this (i had to cut out the name)
I exported to C# from atlas and got:
new BsonArray
{
new BsonDocument("$addFields",
new BsonDocument("result",
new BsonDocument("$strcasecmp",
new BsonArray
{
"$EmployeeFullName",
"Turner Calveron"
}))),
new BsonDocument("$match",
new BsonDocument("result", 0))
}
Which i tried instead of the pipeline variable and it returned zero results also
Any help on where i may be going wrong would be greatly appreciated.
Thank you.