/// <summary>
 /// Delete if exists operation on rank feed table
 /// </summary>
 /// <param name="table">Rank feed table</param>
 /// <param name="partitionKey">Partition key for entity</param>
 /// <param name="feedKey">Key for feed</param>
 /// <param name="itemKey">Item key</param>
 /// <returns>Table operation</returns>
 public static Operation DeleteIfExists(RankFeedTable table, string partitionKey, string feedKey, string itemKey)
 {
     ValidateRankFeedTableParameters(table, partitionKey, feedKey, itemKey);
     return(new Operation()
     {
         Table = table,
         OperationType = OperationType.DeleteIfExists,
         PartitionKey = partitionKey,
         Key = feedKey,
         ItemKey = itemKey
     });
 }
 /// <summary>
 /// Insert or Increment operation on rank feed table
 /// </summary>
 /// <param name="table">Rank feed table</param>
 /// <param name="partitionKey">Key for entity</param>
 /// <param name="feedKey">Key for feed</param>
 /// <param name="itemKey">Item key</param>
 /// <param name="score">Increment value</param>
 /// <returns>Table operation</returns>
 public static Operation InsertOrIncrement(RankFeedTable table, string partitionKey, string feedKey, string itemKey, double score = 1)
 {
     ValidateRankFeedTableParameters(table, partitionKey, feedKey, itemKey);
     return(new Operation()
     {
         Table = table,
         OperationType = OperationType.InsertOrIncrement,
         PartitionKey = partitionKey,
         Key = feedKey,
         ItemKey = itemKey,
         Score = score
     });
 }
        /// <summary>
        /// Query rank feed length
        /// </summary>
        /// <param name="table">Rank feed table</param>
        /// <param name="partitionKey">Partition key for feed</param>
        /// <param name="feedKey">Key for feed</param>
        /// <returns>Rank feed length</returns>
        public async Task <long> QueryRankFeedLengthAsync(
            RankFeedTable table,
            string partitionKey,
            string feedKey)
        {
            this.ValidateQueryRankFeedParameters(table, partitionKey, feedKey);
            switch (table.StorageMode)
            {
            case StorageMode.CacheOnly:
                return(await this.cache.QueryRankFeedLengthAsync(table, partitionKey, feedKey));

            default:
                throw new NotSupportedException();
            }
        }
        /// <summary>
        /// Query rank feed by score async
        /// </summary>
        /// <param name="table">Rank feed table</param>
        /// <param name="partitionKey">Partition key for feed</param>
        /// <param name="feedKey">Key for feed</param>
        /// <param name="startScore">Start score</param>
        /// <param name="endScore">End score</param>
        /// <returns>List of rank feed entities</returns>
        public async Task <IList <RankFeedEntity> > QueryRankFeedByScoreAsync(
            RankFeedTable table,
            string partitionKey,
            string feedKey,
            double startScore,
            double endScore)
        {
            this.ValidateQueryRankFeedParameters(table, partitionKey, feedKey);
            switch (table.StorageMode)
            {
            case StorageMode.CacheOnly:
                return(await this.cache.QueryRankFeedByScoreAsync(table, partitionKey, feedKey, startScore, endScore));

            default:
                throw new NotSupportedException();
            }
        }
        /// <summary>
        /// Query rank feed in reverse async
        /// </summary>
        /// <param name="table">Rank feed table</param>
        /// <param name="partitionKey">Partition key for feed</param>
        /// <param name="feedKey">Key for feed</param>
        /// <param name="cursor">Feed cursor</param>
        /// <param name="limit">Feed count limit</param>
        /// <returns>List of rank feed entities</returns>
        public async Task <IList <RankFeedEntity> > QueryRankFeedReverseAsync(
            RankFeedTable table,
            string partitionKey,
            string feedKey,
            string cursor,
            int limit)
        {
            this.ValidateQueryRankFeedParameters(table, partitionKey, feedKey);
            switch (table.StorageMode)
            {
            case StorageMode.CacheOnly:
                return(await this.cache.QueryRankFeedReverseAsync(table, partitionKey, feedKey, cursor, limit));

            default:
                throw new NotSupportedException();
            }
        }