如果您想查询的文档数据库中的所有文档,请尝试以下代码:
documentClient.CreateDocumentQuery<ProblemDatabaseModel>("").ToList();
请注意,我们可以存储不同的JSON实体documentDB,如果文档属性中没有你数据模型,它会给出一个默认值。我对此有一个简单的测试:
数据模型:
public class Cred
{
[JsonProperty(PropertyName = "id")]
public string ID { get; set; }
[JsonProperty(PropertyName = "title")]
public string Title { get; set; }
[JsonProperty(PropertyName = "credits")]
public int Credits { get; set; }
[JsonProperty(PropertyName = "authordetails")]
public AuthDetail AuthInfo { get; set; }
}
如果documentDB JSON数据是:
{
"id": "CDC103",
"title": "Fundamentals of database design",
"authordetails": {
"Name": "dave",
"Age": 33
},
"custom":"test"
}
client.CreateDocumentQuery<Cred>(UriFactory.CreateDocumentCollectionUri("jambordb", "jamborcols")).ToList();
下面是结果:

从截图中我们知道,我们的数据模型中不包含属性“custom”。信用将给出默认值0.
感谢您的回复。你的回答正是我所要求的,但现在我意识到,我其实并不想要我所有的文件。真的,我想要的是所有类型为ProblemDatabaseModel的文档。有没有一个聪明的方式去与linq而不诉诸字符串查询? linq是否支持类型检查函数,如IS_DEFINED?我为不同的文档类型实现了类似的东西,但它需要我添加属性“nodeType”:“tag”。然后我使用Where子句过滤掉那些属性的文档。谢谢! –
据我所知,目前尚不支持。添加属性是解决此方案的一种解决方法。 –