I'm trying to do a multiple field "distinct" query, which of course isn't possible
(see my attempt here: Selecting a new type from linq query)
Following my realization of this, I've found I'm able to retrieve the data I need by using .group with MongoDB.
Is there any way of using the following query / command within the MongoDB C# wrapper?
disciplines = db.result.group({
key: {DisciplineName:1, DisciplineCode:1},
reduce: function(obj, prev) { if (!obj.hasOwnProperty("DisciplineName")) {
prev.DisciplineName = obj.DisciplineName;
prev.DisciplineCode = obj.DisciplineCode;
}},
initial: { }
});
My Result
class (document) looks like:
public class Result
{
public virtual int ResultId { get; set; }
public virtual string DisciplineCode { get; set; }
public virtual string DisciplineName { get; set; }
public virtual int CompetitorId { get; set; }
//other stuff
}