[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/已關閉了兩個小時... –