Ejemplo n.º 1
0
        public CosmosDb() : base(new AzCosmos.CosmosClient("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="), "Beef.UnitTest", true)
        {
            _mapper = new AutoMapper.Mapper(new MapperConfiguration(c =>
            {
                c.AddProfile <Mapper.AutoMapperProfile>();
                c.CreateMap <Person1, Person1>();
                c.CreateMap <Person2, Person2>();
                c.CreateMap <Person3, Person3>();
            }));

            Persons1 = new CosmosDbContainer <Person1, Person1>(this, CosmosDbArgs.Create(_mapper, "Persons1"));
            Persons2 = new CosmosDbContainer <Person2, Person2>(this, CosmosDbArgs.Create(_mapper, "Persons2"));
            Persons3 = new CosmosDbValueContainer <Person3, Person3>(this, CosmosDbArgs.Create(_mapper, "Persons3"));
        }
Ejemplo n.º 2
0
        public async Task SetUp()
        {
            var c1 = await ReplaceOrCreateContainerAsync(
                new AzCosmos.ContainerProperties
            {
                Id = "Persons1",
                PartitionKeyPath = "/_partitionKey",
                UniqueKeyPolicy  = new AzCosmos.UniqueKeyPolicy {
                    UniqueKeys = { new AzCosmos.UniqueKey {
                                       Paths =            { "/name"}
                                   } }
                }
            }, 400);

            await c1.ImportBatchAsync <CosmosDb, Person1>("Data.yaml");

            var c2 = await ReplaceOrCreateContainerAsync(
                new AzCosmos.ContainerProperties
            {
                Id = "Persons2",
                PartitionKeyPath = "/_partitionKey",
                UniqueKeyPolicy  = new AzCosmos.UniqueKeyPolicy {
                    UniqueKeys = { new AzCosmos.UniqueKey {
                                       Paths =            { "/name"}
                                   } }
                }
            }, 400);

            await c2.ImportBatchAsync <CosmosDb, Person2>("Data.yaml");

            var c3 = await ReplaceOrCreateContainerAsync(
                new AzCosmos.ContainerProperties
            {
                Id = "Persons3",
                PartitionKeyPath = "/_partitionKey",
                UniqueKeyPolicy  = new AzCosmos.UniqueKeyPolicy {
                    UniqueKeys = { new AzCosmos.UniqueKey {
                                       Paths =            { "/type","/value/name" }
                                   } }
                }
            }, 400);

            await c3.ImportValueBatchAsync <CosmosDb, Person3>("Data.yaml");

            // Add other random "type" to Person3.
            var c = new CosmosDbValueContainer <Person1, Person1>(this, CosmosDbMapper.CreateAuto <Person1, Person1>().CreateArgs("Persons3"));
            await c.Container.ImportValueBatchAsync(new Person1[] { new Person1 {
                                                                        Id = 100.ToGuid(), Name = "Greg"
                                                                    } });

            // Load the reference data.
            var rd = await ReplaceOrCreateContainerAsync(
                new AzCosmos.ContainerProperties
            {
                Id = "RefData",
                PartitionKeyPath = "/_partitionKey",
                UniqueKeyPolicy  = new AzCosmos.UniqueKeyPolicy {
                    UniqueKeys = { new AzCosmos.UniqueKey {
                                       Paths =            { "/type","/value/code" }
                                   } }
                }
            }, 400);

            await rd.ImportValueRefDataBatchAsync <ReferenceDataProvider, ReferenceDataProvider>("RefData.yaml");
        }
Ejemplo n.º 3
0
 public CosmosDb() : base(new AzCosmos.CosmosClient("https://localhost:8081", "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="), "Beef.UnitTest", true)
 {
     Persons1 = new CosmosDbContainer <Person1, Person1>(this, CosmosDbMapper.CreateAuto <Person1, Person1>().HasProperty(s => s.Id, d => d.Id, p => p.SetUniqueKey()).CreateArgs("Persons1"));
     Persons2 = new CosmosDbContainer <Person2, Person2>(this, CosmosDbMapper.CreateAuto <Person2, Person2>().HasProperty(s => s.Id, d => d.Id, p => p.SetUniqueKey()).CreateArgs("Persons2"));
     Persons3 = new CosmosDbValueContainer <Person3, Person3>(this, CosmosDbMapper.CreateAuto <Person3, Person3>().HasProperty(s => s.Id, d => d.Id, p => p.SetUniqueKey()).CreateArgs("Persons3"));
 }