예제 #1
0
        public IDocumentStorage StorageFor(Type documentType)
        {
            return(_documentTypes.GetOrAdd(documentType, type =>
            {
                if (type.Closes(typeof(Stream <>)))
                {
                    var aggregateType = type.GetGenericArguments().Single();
                    return Events.StreamMappingFor(aggregateType);
                }


                var mapping = MappingFor(documentType);
                if (mapping is IDocumentStorage)
                {
                    return mapping.As <IDocumentStorage>();
                }


                assertNoDuplicateDocumentAliases();

                IDocumentStorage storage = null;

                var prebuiltType = StoreOptions.PreBuiltStorage
                                   .FirstOrDefault(x => x.DocumentTypeForStorage() == documentType);

                storage = prebuiltType != null ? DocumentStorageBuilder.BuildStorageObject(this, prebuiltType, mapping.As <DocumentMapping>()) : mapping.BuildStorage(this);

                _creation.CreateSchema(this, mapping, () => mapping.ShouldRegenerate(this));

                return storage;
            }));
        }
예제 #2
0
        public IDocumentStorage StorageFor(Type documentType)
        {
            return(_documentTypes.GetOrAdd(documentType, type =>
            {
                var mapping = MappingFor(documentType);
                assertNoDuplicateDocumentAliases();

                var storage = mapping.BuildStorage(this);

                _creation.CreateSchema(this, mapping, () => shouldRegenerate(mapping));

                return storage;
            }));
        }
예제 #3
0
        public IDocumentStorage StorageFor(Type documentType)
        {
            return(_documentTypes.GetOrAdd(documentType, type =>
            {
                var mapping = MappingFor(documentType);
                var storage = DocumentStorageBuilder.Build(mapping);

                if (!DocumentTables().Contains(mapping.TableName))
                {
                    _creation.CreateSchema(this, mapping);
                }

                return storage;
            }));
        }
예제 #4
0
 private void buildSchemaObjectsIfNecessary(IDocumentMapping mapping)
 {
     _creation.CreateSchema(this, mapping, () => mapping.ShouldRegenerate(this));
 }