Example #1
0
        public async Task CanHandleEntityTypeWithStringBasedPartition()
        {
            Expression <Func <DocumentDbFoo1, string> > expression = x => x.MyStringCategory;
            var configurations = GetBaseConfigurations <DocumentDbFoo1>((MemberExpression)expression.Body);

            TableStorageRepository.Configure(typeof(DocumentDbFoo1), configurations);

            const string id = "3";

            await TableStorageRepository.AddAsync(new DocumentDbFoo1
            {
                Id               = id,
                Name             = "Foo 1",
                MyStringCategory = "cat 1"
            }, null);

            await TableStorageRepository.UpdateAsync(new DocumentDbFoo1
            {
                Id               = id,
                Name             = "Foo 1 v2",
                MyStringCategory = "cat 1"
            }, null);

            try
            {
                var item = (await GetByIdAsync <DocumentDbFoo1>(id)).Single();

                item.Name.ShouldBe("Foo 1 v2");
            }
            finally
            {
                TableStorageRepository.DeleteAllAsync <DocumentDbFoo1>(null).GetAwaiter().GetResult();
            }
        }
Example #2
0
        private async Task Seed()
        {
            var list = new List <DocumentDbFoo3>
            {
                new DocumentDbFoo3
                {
                    Id          = "1",
                    Name        = "Foo 1",
                    Category    = "cat 1",
                    Description = "Ha ha ha",
                    Level       = 4,
                    Effective   = new DateTime(2017, 1, 1).ToUtc(),
                    TypeId      = Guid.Parse("AF359AD6-9B8E-43F7-B898-35CEB400051A")
                },
                new DocumentDbFoo3
                {
                    Id          = "2",
                    Name        = "Foo 2",
                    Category    = "cat 1",
                    Description = "Ra ha ha",
                    Level       = 2,
                    Effective   = new DateTime(2018, 1, 1).ToUtc(),
                    TypeId      = Guid.Parse("9B522321-B689-43EC-A3DC-DC17EE2A42DD")
                },
                new DocumentDbFoo3
                {
                    Id          = "3",
                    Name        = "Foo 3",
                    Category    = "cat 2",
                    Description = "Na ha ha",
                    Level       = 3,
                    Effective   = new DateTime(2016, 1, 1).ToUtc(),
                    Expires     = new DateTime(2018, 5, 1).ToUtc(),
                    TypeId      = Guid.Parse("CC562BC9-C2E5-46D8-B701-E5D57F5800B8")
                },
                new DocumentDbFoo3
                {
                    Id          = "4",
                    Name        = "Foo 4",
                    Category    = "cat 1",
                    Description = "Ba ha Ba",
                    Level       = 2,
                    Effective   = new DateTime(2014, 12, 1).ToUtc(),
                    TypeId      = Guid.Parse("4AB97B79-37DB-4AB7-BC32-D3EB1780C8AF")
                },
                new DocumentDbFoo3
                {
                    Id          = "5",
                    Name        = "Bar 5",
                    Category    = "cat 5",
                    Description = "Sa Sa Ba",
                    Level       = 6,
                    Effective   = new DateTime(2014, 1, 1).ToUtc(),
                    Expires     = new DateTime(2015, 12, 31).ToUtc(),
                    TypeId      = Guid.Parse("9B522321-B689-43EC-A3DC-DC17EE2A42DD")
                },
                new DocumentDbFoo3
                {
                    Id          = "6",
                    Name        = "Nest 6",
                    Category    = "ele 6",
                    Description = "JUST ALP",
                    Level       = 8,
                    Effective   = new DateTime(2019, 1, 1).ToUtc(),
                    Expires     = new DateTime(2020, 12, 31).ToUtc(),
                    TypeId      = Guid.Parse("DC742320-F3A4-4DE1-9239-6A9EC68BD430"),
                    IsActive    = true
                },
                new DocumentDbFoo3
                {
                    Id          = "7",
                    Name        = "Desk 7",
                    Category    = "Mal 7",
                    Description = "KO PO LA",
                    Level       = 9,
                    Effective   = new DateTime(2019, 4, 1).ToUtc(),
                    Expires     = new DateTime(2020, 11, 5).ToUtc(),
                    TypeId      = Guid.Parse("D4FB1574-05CF-4422-9477-13D722A5448E"),
                    IsActive    = true
                },
                new DocumentDbFoo3
                {
                    Id          = "8",
                    Name        = "Desk 8",
                    Category    = "Pal 8",
                    Description = "IN AS JA",
                    Level       = 9,
                    Effective   = new DateTime(2019, 4, 15).ToUtc(),
                    Expires     = new DateTime(2021, 11, 9).ToUtc(),
                    TypeId      = Guid.Parse("DE6EFD89-2D62-4E63-98D2-AEA9E622B223"),
                    IsActive    = true
                }
            };

            foreach (var item in list)
            {
                await TableStorageRepository.AddAsync(item, null);
            }
        }