Esempio n. 1
0
        public static TElement Retrieve <TElement>(this IStorageTable table, string partitionKey, string rowKey)
            where TElement : ITableEntity, new()
        {
            if (table == null)
            {
                throw new ArgumentNullException("table");
            }

            IStorageTableOperation operation = table.CreateRetrieveOperation <TElement>(partitionKey, rowKey);
            TableResult            result    = table.ExecuteAsync(operation, CancellationToken.None).GetAwaiter().GetResult();

            return((TElement)result.Result);
        }
Esempio n. 2
0
        public async Task <IValueProvider> BindAsync(TableEntityContext value, ValueBindingContext context)
        {
            IStorageTable          table    = value.Table;
            IStorageTableOperation retrieve = table.CreateRetrieveOperation <TElement>(value.PartitionKey, value.RowKey);
            TableResult            result   = await table.ExecuteAsync(retrieve, context.CancellationToken);

            TElement entity = (TElement)result.Result;

            if (entity == null)
            {
                return(new NullEntityValueProvider <TElement>(value));
            }

            return(new TableEntityValueBinder(value, entity, typeof(TElement)));
        }
Esempio n. 3
0
        public async Task <IValueProvider> BindAsync(TableEntityContext value, ValueBindingContext context)
        {
            IStorageTable          table    = value.Table;
            IStorageTableOperation retrieve = table.CreateRetrieveOperation <DynamicTableEntity>(
                value.PartitionKey, value.RowKey);
            TableResult result = await table.ExecuteAsync(retrieve, context.CancellationToken);

            DynamicTableEntity entity = (DynamicTableEntity)result.Result;

            if (entity == null)
            {
                return(new NullEntityValueProvider <TElement>(value));
            }

            TElement userEntity = Converter.Convert(entity);

            return(new PocoEntityValueBinder <TElement>(value, entity.ETag, userEntity));
        }
Esempio n. 4
0
            async Task <JObject> IAsyncConverter <TableAttribute, JObject> .ConvertAsync(TableAttribute attribute, CancellationToken cancellation)
            {
                IStorageTable table = GetTable(attribute);

                IStorageTableOperation retrieve = table.CreateRetrieveOperation <DynamicTableEntity>(
                    attribute.PartitionKey, attribute.RowKey);
                TableResult result = await table.ExecuteAsync(retrieve, CancellationToken.None);

                DynamicTableEntity entity = (DynamicTableEntity)result.Result;

                if (entity == null)
                {
                    return(null);
                }
                else
                {
                    var obj = ConvertEntityToJObject(entity);
                    return(obj);
                }
            }