Exemple #1
0
        public static void DomeDataMethod()
        {
            // Definition of where our tablestore is
            string TableName = "MyTable";

            // Instanciate or TableStorage class
            TableStorage t = new TableStorage(TableName);

            // Create an object that inherits from TableEntity to be inserted into our table
            string partitionKey = "partitionkey1";
            string rowKey       = "rowkey1";

            SomeDataItem data = new SomeDataItem(partitionKey, rowKey);

            data.String1 = "test.txt";
            data.String2 = "contents";

            t.Insert <SomeDataItem>(data);

            // Check is we can read this data back
            SomeDataItem data2 = t.GetSingle <SomeDataItem>(partitionKey, rowKey);



            List <SomeDataItem> listTableFileItem = t.GetAll <SomeDataItem>(partitionKey);


            // Check if we can modify this data

            data2.String2 = "NewContents";
            t.Replace <SomeDataItem>(data2.PartitionKey, data2.RowKey, data2, true);
            data = t.GetSingle <SomeDataItem>(partitionKey, rowKey);



            // Remove the data
            t.DeleteEntry <SomeDataItem>(partitionKey, rowKey, data2);

            // Remove the table
            t.DeleteTable();
        }
Exemple #2
0
        public static void EmployeeMethod()
        {
            // Definition of where our tablestore is
            string TableName = "Employee";

            // Instanciate or TableStorage class
            TableStorage t = new TableStorage(TableName);

            // Create an object that inherits from TableEntity to be inserted into our table
            string partitionKey = "Contract";
            string rowKey       = "*****@*****.**";

            Employee emp1 = new Employee("Contract", "*****@*****.**");

            emp1.Address = "Bradford";
            emp1.Name    = "Pramod";

            t.Insert <Employee>(emp1);

            Employee emp2 = new Employee("Contract", "*****@*****.**")
            {
                Name = "sachin", Address = "Sangola"
            };
            Employee emp3 = new Employee("Contract", "*****@*****.**")
            {
                Name = "deepak", Address = "Mumbai"
            };
            Employee emp4 = new Employee("Permenent", "*****@*****.**")
            {
                Name = "nana", Address = "Mumbai"
            };
            Employee emp5 = new Employee("Permenent", "*****@*****.**")
            {
                Name = "Jana", Address = "Mumbai"
            };


            t.Insert <Employee>(emp2);
            t.Insert <Employee>(emp3);
            t.Insert <Employee>(emp4);
            t.Insert <Employee>(emp5);


            // Check is we can read this data back
            Employee data2 = t.GetSingle <Employee>(partitionKey, rowKey);



            List <Employee> listTableFileItem = t.GetAll <Employee>(partitionKey);

            // Check if we can modify this data

            emp2.Address = "Lotewadi";
            t.Replace <Employee>(data2.PartitionKey, data2.RowKey, data2, true);
            emp3 = t.GetSingle <Employee>(partitionKey, rowKey);


            // Remove the data
            t.DeleteEntry <Employee>(partitionKey, rowKey, data2);

            // Remove the table
            t.DeleteTable();
        }