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); }
//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); }
/// <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); }
//Thêm Book public void AddBook(BookEntity newBook) { TableOperation insertOperation = TableOperation.Insert(newBook); cloudTable.Execute(insertOperation); }