public async Task delete_record_with_secondary_index_using_sequential_key_mapper()
        {
            var pKeyMapper = new KeyMapper <Employee, int>(e => e.Id.ToString(), int.Parse, e => e.Id,
                                                           id => id.ToString());
            var rKeyMapper = new SequentialKeyMapper <Employee, int>(true);

            var keysConverter = new CalculatedKeysConverter <Employee, int, int>(pKeyMapper, rKeyMapper);

            var logStore =
                new PocoTableStore <Employee, int, int>("IXLogIndex", "UseDevelopmentStorage=true", keysConverter);

            TableStore.AddIndex("Log", logStore);


            var employee = new Employee
            {
                Name       = "Test",
                CompanyId  = 99,
                Id         = 99,
                Department = new Department {
                    Id = 5, Name = "Test"
                }
            };

            await TableStore.InsertAsync(employee);

            await TableStore.DeleteAsync(employee);

            var records = await TableStore.GetByIndexPartitionKeyAsync("Log", 99);

            Assert.AreEqual(1, records.Count());
        }
        public async Task delete_from_index_using_fixed_key_row()
        {
            var pkMapper     = new KeyMapper <Employee, string>(e => e.Name, n => n, e => e.Name, n => n);
            var rkMapper     = new FixedKeyMapper <Employee, string>("emp");
            var keyConverter = new CalculatedKeysConverter <Employee, string, string>(pkMapper, rkMapper);
            PocoTableStore <Employee, int, string> table = null;

            try
            {
                table = new PocoTableStore <Employee, int, string>("IXTestEmployeeUT1", "UseDevelopmentStorage=true", e => e.CompanyId, e => e.Id);

                var index = new PocoTableStore <Employee, string, string>("IXTestEmployeeNameIndexUT1", "UseDevelopmentStorage=true",
                                                                          keyConverter);

                table.AddIndex("Name2", index);


                var employee = new Employee
                {
                    Name       = "Test",
                    CompanyId  = 99,
                    Id         = 99,
                    Department = new Department {
                        Id = 5, Name = "Test"
                    }
                };
                await table.InsertOrReplaceAsync(employee);

                await table.DeleteAsync(employee);
            }
            finally
            {
                await table.DeleteTableAsync();
            }
        }
        public void Init()
        {
            TableStore = new PocoTableStore <Employee, int, int>("IXTestEmployee", "UseDevelopmentStorage=true",
                                                                 e => e.CompanyId, e => e.Id);

            IndexStore = new PocoTableStore <Employee, int, string>("IXTestEmployeeNameIndex", "UseDevelopmentStorage=true",
                                                                    e => e.CompanyId, e => e.Name);

            TableStore.AddIndex("Name", IndexStore);
        }
 public CloudTableRepository(string connectionString)
 {
     tableStore = new PocoTableStore <Todo, string, string>(
         tableName,
         connectionString,
         partitionProperty: todo => todo.UserId,
         rowProperty: todo => todo.Id);
     if (!tableStore.TableExists())
     {
         tableStore.CreateTable();
     }
 }