0
我使用的是Cosmos DB(DocumentDB)和.NET Core。比方說,我有完全不同的文件(簡化的例子):如何並行查詢不同類型的文檔?
public class Market // DocumentType = "market"
{
public string Id {get;set;}
public string Description {get; set;}
}
public class City // DocumentTyupe = "city"
{
public string Id {get;set;}
public string Name {get; set;}
}
要得到所有這些我可以運行兩個查詢一個接一個:
var markets = client.CreateDocumentQuery<Market>()
.Where(x => x.DocumentType == "market").ToList()
var cities = client.CreateDocumentQuery<City>()
.Where(x => x.DocumentType == "city").ToList()
什麼是執行這兩個查詢建議的方法在平行下?所以我想是這樣的:
var markets = QueryMarkets(); // returns Task
var cities = QueryCities(); // returns Task
Task.WhenAll(markets, cities); //execute in parallel
有內置到,我可以從中受益的東西嗎?