The reason you're getting only 900 results back is because you're running into continuation tokens. By default a single request to table service will return a maximum of 1000 entities. It could be less than 1000 entities (and even 0) but never more than 1000. If there are more entities available, then the table service returns a continuation token
which should be used to fetch next set of entities.
So your code should look for the continuation token and should keep on fetching the entities till the time token is returned by table service. Do take a look at the sample code below:
private IEnumerable<T> FetchAllEntities()
{
List<T> allEntities = new List<T>();
CloudStorageAccount storageAccount = CloudStorageAccount.DevelopmentStorageAccount;
CloudTable table = storageAccount.CreateCloudTableClient().GetTableReference("MyTable");
Microsoft.WindowsAzure.Storage.Table.TableContinuationToken tableContinuationToken = null;
do
{
var queryResponse = table.ExecuteQuerySegmented<T>(null, tableContinuationToken, null, null);
tableContinuationToken = queryResponse.ContinuationToken;
allEntities.AddRange(queryResponse.Results);
}
while (tableContinuationToken != null);
return allEntities;
}
Update
For your error, try changing the following
public class TableRepository<T> : IRepository<T>
where T : TableEntity
to
public class TableRepository<T> : IRepository<T>
where T : TableEntity, new()
notice the addition of new()
after TableEntity
.