Ask questionsFirestore - Limit not returning correct number of records

Library: Google.Cloud.Firestore 2.3.1

When attempting to query a range of dates, I am unable to return the correct number of records when including a limit in the query. In the example below, without the limit selected, it returns over 5k records. When I apply a limit of 5k, it only returns 2256 records.

        public async Task<List<T>> QueryRecords<T>(Query query) where T : FireStoreBase
            QuerySnapshot querySnapshot = null;
            querySnapshot = await query.GetSnapshotAsync();            
            List<T> list = new List<T>();
            var count = querySnapshot.Documents.Count;
            foreach (DocumentSnapshot documentSnapshot in querySnapshot.Documents)
                if (documentSnapshot.Exists)
                    Dictionary<string, object> record = documentSnapshot.ToDictionary();                    
                    T newItem = documentSnapshot.ConvertTo<T>();
                    newItem.Id = documentSnapshot.Id;
            return list;

        public async Task<List<SomeData>> GetSchedulesFilterByDate(DateTime startDate, DateTime endDate, int recordsLimit = 0)
            if (recordsLimit == 0) recordsLimit = _recordsLimit;

            Query query = repo.fireStoreDb.Collection(collectionName).OrderBy("SomeDate")
                                            .WhereGreaterThanOrEqualTo("SomeDate", startDate)
                                            .WhereLessThanOrEqualTo("SomeDate", endDate).Limit(5000);

            return await repo.QueryRecords<SomeData>(query);

Answer questions neil-gok


I wonder if you use a more complex model, if you would see the same results. My model has nested objects, which might make the difference.


Github User Rank List