コード例 #1
0
        public async void Save(IProduct product)
        {
            try
            {
                var table = AzureTableHelper.GetCloudTable(azureTableName);

                ProductDTO ent = new ProductDTO(GetNewPartitionKey(), GetNewUniqueKey());
                ent.SetProduct(product);

                TableOperation ins = TableOperation.Insert(ent);

                await table.ExecuteAsync(ins);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
        public void Save(string JSONData)
        {
            try
            {
                var table = AzureTableHelper.GetCloudTable("HHIUnstructured");

                var ent = new UnstructuredTable(GetNewUniqueKey(), GetNewUniqueKey())
                {
                    RawData = JSONData
                };

                table.Execute(TableOperation.Insert(ent));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #3
0
        public IEnumerable <IProduct> GetAll()
        {
            var retList = new List <Product>();

            var table = AzureTableHelper.GetCloudTable(azureTableName);

            TableQuery <ProductDTO> query = new TableQuery <ProductDTO>().Where(TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.NotEqual, ""));

            foreach (ProductDTO entity in table.ExecuteQuery(query))
            {
                retList.Add(new Product()
                {
                    Description = entity.Description, Id = entity.ProdId, Price = Convert.ToDecimal(entity.Price)
                });
            }

            return(retList);
        }