From 74a0e83ea894cce87d66929d0bcb15c866a979e1 Mon Sep 17 00:00:00 2001 From: Thomas Hounsell Date: Tue, 10 Nov 2015 10:58:59 +0000 Subject: [PATCH] It's fixed and I haven't topped myself I guess this counts as "exceeds expectations" --- BuildFeed/Models/Build/Build-Version.cs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/BuildFeed/Models/Build/Build-Version.cs b/BuildFeed/Models/Build/Build-Version.cs index 51f93dd..e926a49 100644 --- a/BuildFeed/Models/Build/Build-Version.cs +++ b/BuildFeed/Models/Build/Build-Version.cs @@ -54,19 +54,22 @@ public async Task> SelectVersion(int major, int minor, int skip public async Task> SelectVersions() { var result = await _buildCollection.Aggregate() - .Group(b => new BuildVersion() - { - Major = b.MajorVersion, - Minor = b.MinorVersion, - }, - // incoming bullshit hack - bg => new Tuple(bg.Key)) - .SortByDescending(b => b.Item1.Major) - .ThenByDescending(b => b.Item1.Minor) + // the group method in mongodb's c# driver sucks balls and throws a hissy fit over far too much. + .Group(b => new BuildVersion(b.MajorVersion, b.MinorVersion), bg => new BsonDocument()) .ToListAsync(); // work ourselves out of aforementioned bullshit hack - return result.Select(b => b.Item1).ToList(); + var typed = from r in result + select new BuildVersion + { + Major = (byte)result.First()["_id"]["Major"].ToInt32(), + Minor = (byte)result.First()["_id"]["Minor"].ToInt32() + }; + + return (from t in typed + orderby t.Major descending, + t.Minor descending + select t).ToList(); } [DataObjectMethod(DataObjectMethodType.Select, false)]