[Test]
public void Can_Get_All()
{
var repository = new RavenRepository<Motorcycle>();
repository.DeleteAll();
repository.Store(new Motorcycle {Make = "Datsun", YearManufactured = 1972});
repository.Store(new Motorcycle {Make = "Toyota", YearManufactured = 2002});
IList<Motorcycle> savedThings = repository.GetAll();
Assert.IsTrue(savedThings.Count == 2);
}
RavenRepository.GetAll()如何从RavenDB获取所有文档?
public IList<T> GetAll()
{
using (IDocumentSession session = _collection.OpenSession())
{
return session.Query<T>().ToList(); // Throws exception
}
}
运行此测试抛出异常:
Raven.Abstractions.Exceptions.IndexCompilationException:无法理解的查询:变量初始值选择必须具有lambda表达式用物体创造表情
为什么?我如何才能从RavenDB中获取T类型的所有文档?
我会阅读文档,但http://ravendb.net/已关闭了两个小时... –