public static Task <IEnumerable <T> > WhereAsync <T>(this IAzureTableStorage <T> tableStorage, string partitionKey,
                                                             DateTime from, DateTime to, ToIntervalOption intervalOption, Func <T, bool> filter = null)
            where T : ITableEntity, new()
        {
            var rangeQuery = QueryGenerator <T> .BetweenQuery(partitionKey, from, to, intervalOption);

            return(filter == null
                ? tableStorage.ExecuteQueryAsync(rangeQuery)
                : tableStorage.ExecuteQueryAsync(rangeQuery, filter));
        }
        public static Task <IEnumerable <T> > WhereAsync <T>(this IAzureTableStorage <T> tableStorage, string partitionKey,
                                                             int year, int month, Func <T, bool> filter = null)
            where T : ITableEntity, new()
        {
            var from = new DateTime(year, month, 1);
            var to   = from.AddMonths(1);

            var rangeQuery = QueryGenerator <T> .BetweenQuery(partitionKey, from, to, ToIntervalOption.ExcludeTo);

            return(filter == null
                ? tableStorage.ExecuteQueryAsync(rangeQuery)
                : tableStorage.ExecuteQueryAsync(rangeQuery, filter));
        }
        public static Task <IEnumerable <T> > GetDataRowKeyOnlyAsync <T>(this IAzureTableStorage <T> tableStorage, string rowKey)
            where T : ITableEntity, new()
        {
            var query = QueryGenerator <T> .RowKeyOnly.GetTableQuery(rowKey);

            return(tableStorage.ExecuteQueryAsync(query));
        }
        public static async Task <IEnumerable <T> > ScanAndGetList <T>(this IAzureTableStorage <T> tableStorage, string partitionKey, Func <T, bool> condition)
            where T : class, ITableEntity, new()
        {
            var result = new List <T>();

            var query = QueryGenerator <T> .PartitionKeyOnly.GetTableQuery(partitionKey);

            await tableStorage.ExecuteQueryAsync(query, items =>
            {
                var itemsToAdd = items.Where(condition);
                result.AddRange(itemsToAdd);
            });

            return(result);
        }