Can sortCount be accessed through .NET SDK?

I am trying to find a way to get to Metrics.sortCount using .NET SDK.

It doesn’t appear to be included in the SDK

Is there another way of getting it?

@enko -

There is no other way from the SDK atm, but I created a Jira ticket to add sortCount to the response in the next SDK release.


1 Like

@jmorris thank you!

I’ve modified the driver temporarely until you release it.


        [DataMember(Name = "sortCount", IsRequired=false)]
        public uint SortCount { get; set; }

to Metrics.cs

@enko -

Awesome, I also just pushed a patch for review

Since you also patched it, you can always send a Pull Request and sign the CLA, then you’ll get credit as an official contributor. If you do, i’ll abandon my patch and take yours, if you add a unit test :slight_smile:



Its ok, you got it! Thank you!

I think test is something like:

        public void Tests_SortCount_To_Return_With_GroupBy_and_Limit ()
            using (var bucket = _cluster.OpenBucket())
                var queryRequest = new QueryRequest()
                    .Statement("SELECT * FROM `beer-sample` ORDER BY meta(`beer-sample`).id LIMIT 0")

                var result = bucket.Query<dynamic>(queryRequest);
                Assert.IsTrue(result.Success, result.GetErrorsAsString());
                Assert.Greater(result.Metrics.SortCount, 0);

I haven’t tested the test. Also not sure if IsRequired=false is needed, since I believe sortCount is omitted on non-grouped queries.

1 Like