static void Main(string[] args)
        {
            // insert your own connection string here, or use one of the other options:
            var tableStorage = CloudStorage
                .ForAzureConnectionString("DefaultEndpointsProtocol=https;AccountName=YOURACCOUNT;AccountKey=YOURKEY")
                .BuildTableStorage();

            // 'books' is the name of the table
            var books = new CloudTable<Book>(tableStorage, "books");

            var potterBook = new Book { Author = "J. K. Rowling", Title = "Harry Potter" };
            var poemsBook = new Book { Author = "John Keats", Title = "Complete Poems" };

            // inserting (or updating record in Table Storage)
            books.Upsert(new[]
                {
                    new CloudEntity<Book> {PartitionKey = "UK", RowKey = "potter", Value = potterBook},
                    new CloudEntity<Book> {PartitionKey = "UK", RowKey = "poems", Value = poemsBook}
                });

            // reading from table
            foreach(var entity in books.Get())
            {
                Console.WriteLine("{0} by {1} in partition '{2}' and rowkey '{3}'",
                    entity.Value.Title, entity.Value.Author, entity.PartitionKey, entity.RowKey);
            }

            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // TODO: change your connection string here
            var providers = Standalone.CreateProviders("DefaultEndpointsProtocol=https;AccountName=;AccountKey=");
            
            // 'books' is the name of the table
            var books = new CloudTable<Book>(providers.TableStorage, "books");

            var potterBook = new Book { Author = "J. K. Rowling", Title = "Harry Potter" };
            var poemsBook = new Book { Author = "John Keats", Title = "Complete Poems" };

            // inserting (or updating record in Table Storage)
            books.Upsert(new[]
                {
                    new CloudEntity<Book> {PartitionKey = "UK", RowKey = "potter", Value = potterBook},
                    new CloudEntity<Book> {PartitionKey = "UK", RowKey = "poems", Value = poemsBook}
                });

            // reading from table
            foreach(var entity in books.Get())
            {
                Console.WriteLine("{0} by {1} in partition '{2}' and rowkey '{3}'",
                    entity.Value.Title, entity.Value.Author, entity.PartitionKey, entity.RowKey);
            }

            Console.WriteLine("Press enter to exit.");
            Console.ReadLine();
        }