Example #1
0
        public void Apply()
        {
            foreach (var cs in _tenantConnectionStrings)
            {
                using (var documentStore = DocumentStoreFactory.CreateStore(cs, null))
                    using (var dbContext = new RavenDbContext(documentStore.OpenSession(), documentStore.OpenAsyncSession()))
                    {
                        dbContext.Truncate <ProgrammeDictionary>();

                        var cache = new Dictionary <string, ProgrammeDictionary>();

                        foreach (var programme in dbContext.Specific.GetAllWithNoTracking <Programme>())
                        {
                            if (!cache.TryGetValue(programme.ExternalReference, out var dictionary))
                            {
                                dictionary = new ProgrammeDictionary {
                                    ExternalReference = programme.ExternalReference
                                };
                                cache.Add(programme.ExternalReference, dictionary);
                            }

                            dictionary.ProgrammeName  = programme.ProgrammeName;
                            dictionary.Description    = programme.Description;
                            dictionary.Classification = programme.Classification;
                        }

                        dbContext.AddRange(cache.Values.ToArray());
                    }
            }
        }
Example #2
0
        public void CreateTest()
        {
            var store = new EmbeddableDocumentStore();
            store.Initialize();

            using (var context = new RavenDbContext(store))
            {
                var target = new RavenDbRepository<Foo>(context);
                var foo = new Foo { Bar = "Foo" };
                target.Insert(foo);

                var actual = target.Single(p => p.Bar == "Foo");

                Assert.IsNotNull(actual);
            }
        }
Example #3
0
 ///<inheritdoc/>
 public MaterialRepository(RavenDbContext ravenDbContext, IMapper mapper)
 {
     _ravenDbContext = ravenDbContext ?? throw new ArgumentNullException(nameof(ravenDbContext));
     _mapper         = mapper ?? throw new ArgumentNullException(nameof(mapper));
 }