I am getting two different results while I would expect the result to be same no matter how I query the database. In the result of query 1, I am getting a list of value pairs like
NY 3
AL 6
WI 5
etc..
But when I run query 2 to test if my values are accurate or not.. and when I specifically run and get by state “NY”, I am getting a totally different number for NY. They are just not matching for any state. I am not sure any more as to which one is the accurate number.
Query 1:
//Edit
int countTheaters = session.Query<Theaters>()
.Count();
var TheaterByStateList = session.Query<Theaters>()
.Take(countTheaters)
.ToList()
.GroupBy(x => x.State)
.OrderBy(x =>x.Count())
.ToDictionary(x => x.Key, x => x.Count());
Query 2:
int TheaterCountByState = session.Query<Theaters>()
.Where(x => x.State== "NY")
.Count();
The reason for this is, that .Take() only returns the maximum number of records that have been set in the RavenDB server configuration. This is because ravens safe-by-design philosophy that should make you fail early (in development) and thus help you avoid a lot of pain that could happen if you weren’t aware of the means of not paging (something that people commonly run into with NHibernate or EF2).
So by default, without specifiying anything else, you only get 128 records. You can change that on the client, but you will never get more records at once than the number that has been set on the server (1024 I think, but shouldn’t care anyway – there’s no reason why somebody would want to change these limits).