【发布时间】:2013-07-04 13:57:38
【问题描述】:
我在 localhost:8080 上运行 RavenDB 服务器。我在那里创建了一个数据库“CountriesRegions”,其中包含“Country”和“Region”的文档,例如:
文档 ID 27:
{
"Country": "Sweden",
"Region": "EU"
}
我有一个CountryRegion 类:
public class CountryRegion
{
public string Id { get; set; }
public string Country { get; set; }
public string Region { get; set; }
public CountryRegion(){}
}
以下代码包含一个test 对象,其中Country 设置为“瑞典”,Region 设置为“欧盟”,正如预期的那样:
using (var session = _countriesDocumentStore.OpenSession())
{
var test = session.Load<CountryRegion>("27");
}
但是,在这段代码中test 是一个空列表:
using (var session = _countriesDocumentStore.OpenSession())
{
var test = session.Query<CountryRegion>()
.Customize(cr => cr.WaitForNonStaleResults())
.ToList();
}
怎么了?
【问题讨论】:
-
您能否也发布该文档的元数据?
-
您可能打算加载“countryRegions/27”而不仅仅是“27”。你能显示你将文档写入数据库的代码吗?