Пример #1
0
        public async Task transform_for_tenants()
        {
            var user1 = new MultiTenantUser()
            {
                FirstName = "Jeremy", LastName = "Miller"
            };
            var user2 = new MultiTenantUser {
                FirstName = "Corey", LastName = "Kaylor"
            };
            var user3 = new MultiTenantUser {
                FirstName = "Tim", LastName = "Cools", UserName = "******"
            };

            await theStore.BulkInsertAsync("Purple", new MultiTenantUser[] { user1, user2 });

            await theStore.BulkInsertAsync("Orange", new MultiTenantUser[] { user3 });

            await theStore.TransformAsync("Purple", x => x.All <MultiTenantUser>("default_username"));

            using (var query = theStore.QuerySession("Purple"))
            {
                query.Load <MultiTenantUser>(user1.Id).UserName.ShouldBe("jeremy.miller");
            }

            using (var query = theStore.QuerySession("Orange"))
            {
                query.Load <MultiTenantUser>(user3.Id).UserName.ShouldBe("NotTransformed");
            }
        }