示例#1
0
        public async Task <List <T> > QueryAsync(DateTimeOffset date, CancellationToken cancellationToken = default(CancellationToken))
        {
            var key   = DateTimeKey.GetDateKey(date);
            var query = TableQueryUtil.PartitionKey(key);

            return(await AzureUtil.QueryAsync <T>(Table, query, cancellationToken));
        }
示例#2
0
        private static string GetQueryString(DateTimeOffset startDate, DateTimeOffset endDate)
        {
            var startKey = DateTimeKey.GetDateKey(startDate);
            var endKey   = DateTimeKey.GetDateKey(endDate);

            if (startKey == endKey)
            {
                return(TableQueryUtil.PartitionKey(startKey));
            }

            return(TableQueryUtil.And(
                       TableQueryUtil.PartitionKey(startKey, ColumnOperator.GreaterThanOrEqual),
                       TableQueryUtil.PartitionKey(endKey, ColumnOperator.LessThanOrEqual)));
        }
示例#3
0
        /// <summary>
        /// Query async for a single entity value matching the specified key
        /// </summary>
        public static async Task <T> QueryAsync <T>(
            CloudTable table,
            EntityKey key,
            CancellationToken cancellationToken = default(CancellationToken))
            where T : ITableEntity, new()
        {
            var query   = new TableQuery <T>().Where(TableQueryUtil.Key(key));
            var segment = await table.ExecuteQuerySegmentedAsync(query, null, cancellationToken);

            if (segment.Results.Count == 0)
            {
                return(default(T));
            }

            return(segment.Results[0]);
        }
示例#4
0
        public IEnumerable <T> Query(DateTimeOffset date, CancellationToken cancellationToken = default(CancellationToken))
        {
            var key = DateTimeKey.GetDateKey(date);

            return(AzureUtil.Query <T>(Table, TableQueryUtil.PartitionKey(key)));
        }