Ejemplo n.º 1
0
        /// <summary>
        /// This returns the query-only version of the document storage
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <typeparam name="TId"></typeparam>
        /// <returns></returns>
        /// <exception cref="DocumentIdTypeMismatchException"></exception>
        internal IDocumentStorage <T, TId> QueryStorageFor <T, TId>()
        {
            var storage = _providers.StorageFor <T>().QueryOnly;

            if (storage is IDocumentStorage <T, TId> s)
            {
                return(s);
            }


            throw new DocumentIdTypeMismatchException(storage, typeof(TId));
        }
Ejemplo n.º 2
0
            public DocumentProvider <T> BuildPersistence(IProviderGraph graph, SubClassMapping mapping)
            {
                var inner = graph.StorageFor <TRoot>();

                return(new DocumentProvider <T>()
                {
                    QueryOnly = new SubClassDocumentStorage <T, TRoot, TId>((IDocumentStorage <TRoot, TId>)inner.QueryOnly, mapping),
                    Lightweight = new SubClassDocumentStorage <T, TRoot, TId>((IDocumentStorage <TRoot, TId>)inner.Lightweight, mapping),
                    IdentityMap = new SubClassDocumentStorage <T, TRoot, TId>((IDocumentStorage <TRoot, TId>)inner.IdentityMap, mapping),
                    DirtyTracking = new SubClassDocumentStorage <T, TRoot, TId>((IDocumentStorage <TRoot, TId>)inner.DirtyTracking, mapping),
                    BulkLoader = new SubClassBulkLoader <T, TRoot>(inner.BulkLoader)
                });
            }
Ejemplo n.º 3
0
        public DocumentProvider <T> StorageFor <T>()
        {
            if (_storage.TryFind(typeof(T), out var stored))
            {
                return(stored.As <DocumentProvider <T> >());
            }

            Tenant.EnsureStorageExists(typeof(T));
            var persistence = _inner.StorageFor <T>();

            _storage = _storage.AddOrUpdate(typeof(T), persistence);

            return(persistence);
        }
Ejemplo n.º 4
0
 public IDocumentStorage <T> StorageFor <T>()
 {
     return(selectStorage(_providers.StorageFor <T>()));
 }
Ejemplo n.º 5
0
 public IDocumentSourceCode Load(IProviderGraph providers)
 {
     return(providers.StorageFor <T>());
 }
Ejemplo n.º 6
0
 public IDocumentStorage Find(IProviderGraph providers)
 {
     return(providers.StorageFor <T>().Lightweight);
 }