RavenDb使用Include进行LoadAsync的单个Db请求

时间:2015-06-29 05:41:52

标签: c# async-await ravendb

我正在尝试使用.Include()让RavenDb执行单个请求,但是在使用异步方法时我会收到多个请求。

public class List
{
    public Guid Id { get; set; }           
    public List<string> Items { get; set; }                
}

public class ListItem
{
    public Guid Id { get; set; }           
}

List.Items是Id引用Item文档的集合。

1。同步方法 - 单一请求

var session = store.OpenSession();
var listId = new Guid("181aaacd-6505-4a49-96a8-c2da5abb426a");
var list = session.Include<List, ListItem>(bp => bp.Items).Load<List>(listId);
return session.Load<ListItem>(list.Items);

正确地给出了

Request # 412: GET - 2 ms - listdb - 304 - /queries/?&include=Items(Item/)&id=Lists%2181aaacd-6505-4a49-96a8-c2da5abb426a

2。异步方法 - 多个请求**

var session = store.OpenAsyncSession();
var listId = new Guid("181aaacd-6505-4a49-96a8-c2da5abb426a");
var list = await session.Include<List, ListItem>(l => l.Items).LoadAsync<List>(listId);
return await session.LoadAsync<ListItem>(list.Items);

生成2个不是我期望的请求

Request #   1: GET     -     0 ms - listdb - 304 - /queries/?include=Items(Item/)&id=Lists%22181aaacd-6505-4a49-96a8-c2da5abb426a
Request #   2: GET     -     0 ms - listdb - 304 - /queries/?&id=Items%2F3d75a8d6-a12d-4dd7-8c35-4e093a66adaa

这是预期的吗? 异步问题?

Raven Build 2951,版本2.5.0 / 6dce79a

0 个答案:

没有答案