0
例:次のコレクションを想定しましょう。 ThrashMetalDocumentsCollectionとSpeedMetalDocumentsCollection(両方とも同じHeavyMetalRecordDocument構造を持つコレクション)。両方のコレクションのすべてのレコードを照会して戻し、releaseDate(最古のもの)とrating(高低)でソートするにはどうすればよいですか?ありがとう! \ M/\ M/MongoDBはソート順の2つのコレクションを照会します
static async Task getAllRecords()
{
var builder = Builders<HeavyMetalRecordDocument>.Filter;
//var filter;
using (var cursor = await ThrashMetalDocumentsCollection.Find()
.Sort(Builders<HeavyMetalRecordDocument>.Sort.Ascending(x => x.rating))
.ToCursorAsync())
{
while (await cursor.MoveNextAsync())
{
foreach (var doc in cursor.Current)
{
//Do Something…
}
}
}
}
public class HeavyMetalRecordDocument
{
public ObjectId Id { get; set; }
public String artist { get; set; }
public String title { get; set; }
public DateTime releaseDate { get; set; }
public int rating { get; set; } // 1-10
}
私は若干の調整を行い、範囲を1つのコレクションに限定します。ありがとう! – 80sRocker