Hope someone can help me,
Via this call i retrieve the OrderBy parameter.
string sortField = docQueryHelp.GetSortField(filter.OrderBy);
bool ascending = filter.IsAsc ?? false;
In “filter” the OrderBy value is “EndTime” (field in MongoDB).
This is set via a php script that talks to the windows server.
$live_specification_filter->OrderBy = ‘EndTime’;
$live_specification_filter->IsAsc = true;
Now i tried to have two fields to sort on by passing this in the php script:
$live_specification_filter->OrderBy = ‘EndTime, Specification.Category’;
$live_specification_filter->IsAsc = true;
So first sort on EndTime then Specification.Category.
Using only 1 OrderBy value works, but how can set/format the above OrderBy
in the .Net code?
string sortField = docQueryHelp.GetSortField(filter.OrderBy);
Would be great if you could help me.
--
You received this message because you are subscribed to the Google Groups "mongodb-csharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-cshar...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
The driver binaries are available on NuGet at:
http://www.nuget.org/List/Packages/mongocsharpdriver
The driver binaries are also available at:
https://github.com/mongodb/mongo-csharp-driver/releases/download/v1.8.3.9/CSharpDriver-1.8.3.zip
https://github.com/mongodb/mongo-csharp-driver/releases/download/v1.8.3.9/CSharpDriver-1.8.3.msi
The following source code your provided doesn't match the C# driver API:
MongoCollection does not have a Find method that takes three parameters. MongoCursor does not have a Sort method or a Documents property.
This code should look something like this:
var cursor = collection.Find(where)
.SetLimit(count)
.SetSkip(start)
.SetSortOrder(ascending ? SortBy.Ascending(sortField) : SortBy.Descending(sortField));
var results = cursor.ToArray();