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; })); }
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; })); }
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; })); }
private void buildSchemaObjectsIfNecessary(IDocumentMapping mapping) { _creation.CreateSchema(this, mapping, () => mapping.ShouldRegenerate(this)); }