예제 #1
0
        public BookEntity FindBook(int rowKey, string partitionKey)
        {
            //Lấy Book trong database đưa vào PartitionKey và RowKey
            TableOperation retrieveOperation = TableOperation.Retrieve <BookEntity>(partitionKey, rowKey.ToString());
            TableResult    retrieveResult    = cloudTable.Execute(retrieveOperation);
            BookEntity     book = (BookEntity)retrieveResult.Result;

            return(book);
        }
예제 #2
0
        //Xóa bảng Books
        public void DeleteBook(int rowKey, string partitionKey)
        {
            //Lấy Book trong database đưa vào PartitionKey và RowKey
            TableOperation retrieveOperation = TableOperation.Retrieve <BookEntity>(partitionKey, rowKey.ToString());
            TableResult    retrieveResult    = cloudTable.Execute(retrieveOperation);
            BookEntity     deleteBook        = (BookEntity)retrieveResult.Result;
            //Xóa book
            TableOperation deleteOperation = TableOperation.Delete(deleteBook);

            cloudTable.Execute(deleteOperation);
        }
예제 #3
0
        /// <summary>
        /// Async insert a new entity into the Book table.
        /// </summary>
        /// <param name="bookDTO">The BookDTO object</param>
        public static async void CreateAsync(BookDTO bookDTO)
        {
            CloudTable bookTable = GetTable();
            await bookTable.CreateIfNotExistsAsync();

            // Convert bookDTO into bookEntity
            BookEntity bookEntity = new BookEntity(bookDTO);

            // Create the TableOperation that inserts the customer entity.
            TableOperation insertOperation = TableOperation.Insert(bookEntity);

            // Execute the insert operation.
            await bookTable.ExecuteAsync(insertOperation);
        }
예제 #4
0
        //Thêm Book
        public void AddBook(BookEntity newBook)
        {
            TableOperation insertOperation = TableOperation.Insert(newBook);

            cloudTable.Execute(insertOperation);
        }