Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RavenDB : A Simple Query<T>().ToList() returns 0 results

Tags:

ravendb

Im using RavenDB (in server mode running @localhost:3000), and ASP.NET MVC3

I have this code segment which stopped working from build 289. It did work couple of times before, not sure if it was the update to 322 or something I did.

Session.Query<Post>().ToList().ForEach(Session.Delete);

It was deleting all Posts when I tried a while back, (I only have around 50 odd posts in my sample data, and 500 more to come in) and only changes I can see is these two occurring at Runtime

A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in Raven.Client.Lightweight.dll

And this log appears in the visual studio output window when the code segment (Session.Delete) above is actually running

Executing query '' on index 'dynamic/Posts' in 'http://localhost:3000'
Query returned 0/0 results

And in Raven logs, (a text file) there is nothing untoward

Request #   7: GET     -    46 ms - ZaszStore  - 200 - /indexes/dynamic/Posts?query=&start=0&pageSize=128&aggregation=None

This Query runs just fine :

Session.Load<Post>("MyPostId")

and fetches the correct Post Instance.

Why is a simple Session.Query().ToList() returning 0 results all the time? And Session.Query().Count() returns 0 always. What could cause this behavior, considering the SilverLight-UI (SL-UI) of Raven DB clearly shows that there are 50-odd posts in the DB?

The "Raven-Entity-Name" is correctly filled.

like image 921
Zasz Avatar asked Apr 06 '11 12:04

Zasz


1 Answers

For this sort of query you can get all the docs like so:

documentStore.DatabaseCommands.StartsWith("post", <page>, <size>) 

That should be easier and more efficient than issuing a query to return all the docs as it pulls them directly from the datastore, bypassing the Lucene indexes.

However it only works when you want to get all the docs that have the save prefix as their Id.

like image 89
Matt Warren Avatar answered Oct 14 '22 21:10

Matt Warren