到目前为止,我尝试过以下方法:
public class Widget
{
    public int Id;
    public string Name;
}
public static class Main
{
    public static void Main()
    {
        // Initialize store and preload with widgets...
        using (var session = store.OpenSession())
        {
            var widgets = session.Load<Widget>();
            foreach(var widget in widgets)
            {
                Console.WriteLine(widget.Name);
            }
        }
    }
}
我已经能够通过添加索引然后使用该索引作为查询来加载所有:
var store = new DocumentStore();
store.DatabaseCommands.PutIndex("AllWidgets", new IndexDefinition<Widget>
{
    Map = widget => from widget in widgets
                   select new { widget }
});
// Back in Main
var widgets = session.Query<Widget>("AllWidgets");
// Do stuff with widgets.
有没有办法在Widget不必创建索引的情况下获取所有类型的文档?
此时我只是在沙盒环境中使用RavenDB.我意识到这通常不是获取数据的最佳方法.
Rob*_*ton 11
是
使用DocumentsByName查询 - 这个我可以解决的问题目前在客户端界面中并不直观,但看起来像这样:
documentSession.LuceneQuery<ImageDocument>("Raven/DocumentsByEntityName")
                 .Where("Tag:Widgets")
                 .Take(100)
                 .ToArray();
如果您有时知道HTTP API,它会有所帮助:)
注意:注意它是如何复数的,这是一个约定,可以被覆盖.
注意:在不稳定的前叉中(很可能很快就会稳定,上面的内容很容易实现)
documentSession.Query<ImageDocument>().Take(100).ToArray()
好多了