本文整理汇总了C#中Raven.Database.DocumentDatabase类的典型用法代码示例。如果您正苦于以下问题:C# DocumentDatabase类的具体用法?C# DocumentDatabase怎么用?C# DocumentDatabase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DocumentDatabase类属于Raven.Database命名空间,在下文中一共展示了DocumentDatabase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public static void Init()
{
if (database != null)
return;
lock (locker)
{
if (database != null)
return;
try
{
var ravenConfiguration = new RavenConfiguration();
HttpEndpointRegistration.RegisterHttpEndpointTarget();
database = new DocumentDatabase(ravenConfiguration);
database.SpinBackgroundWorkers();
server = new HttpServer(ravenConfiguration, database);
server.Init();
}
catch
{
if (database != null)
{
database.Dispose();
database = null;
}
if (server != null)
{
server.Dispose();
server = null;
}
throw;
}
}
}
示例2: AfterBackupRestoreCanQueryIndex_CreatedAfterRestore
public void AfterBackupRestoreCanQueryIndex_CreatedAfterRestore()
{
db.Put("ayende", null, JObject.Parse("{'email':'[email protected]'}"), JObject.Parse("{'Raven-Entity-Name':'Users'}"), null);
db.StartBackup("raven.db.test.backup");
WaitForBackup();
db.Dispose();
DeleteIfExists("raven.db.test.esent");
DocumentDatabase.Restore(new RavenConfiguration(), "raven.db.test.backup", "raven.db.test.esent");
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = "raven.db.test.esent" });
db.SpinBackgroundWorkers();
QueryResult queryResult;
do
{
queryResult = db.Query("Raven/DocumentsByEntityName", new IndexQuery
{
Query = "Tag:[[Users]]",
PageSize = 10
});
} while (queryResult.IsStale);
Assert.Equal(1, queryResult.Results.Count);
}
示例3: AfterBackupRestoreCanQueryIndex_CreatedAfterRestore
public void AfterBackupRestoreCanQueryIndex_CreatedAfterRestore()
{
db.Put("ayende", null, RavenJObject.Parse("{'email':'[email protected]'}"), RavenJObject.Parse("{'Raven-Entity-Name':'Users'}"), null);
db.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
DocumentDatabase.Restore(new RavenConfiguration(), BackupDir, DataDir, s => { }, defrag: true);
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = DataDir });
db.SpinBackgroundWorkers();
QueryResult queryResult;
do
{
queryResult = db.Query("Raven/DocumentsByEntityName", new IndexQuery
{
Query = "Tag:[[Users]]",
PageSize = 10
}, CancellationToken.None);
} while (queryResult.IsStale);
Assert.Equal(1, queryResult.Results.Count);
}
示例4: GeneralStorage
public GeneralStorage()
{
db = new DocumentDatabase(new RavenConfiguration
{
DataDirectory = DataDir,
});
}
示例5: Esent
public Esent()
{
db = new DocumentDatabase(new RavenConfiguration
{
DataDirectory = DataDir,
});
}
示例6: AfterIncrementalBackupRestoreCanReadDocument
public void AfterIncrementalBackupRestoreCanReadDocument()
{
db.Put("ayende", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
db.Put("itamar", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.StartBackup(BackupDir, true, new DatabaseDocument());
WaitForBackup(db, true);
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
DocumentDatabase.Restore(new RavenConfiguration
{
Settings =
{
{"Raven/Esent/CircularLog", "false"}
}
}, BackupDir, DataDir, s => { });
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = DataDir });
var jObject = db.Get("ayende", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
jObject = db.Get("itamar", null).ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
}
示例7: ReplicateDatabaseCreation
public void ReplicateDatabaseCreation( DocumentDatabase database )
{
InstanceDescription self = null;
var replicationTargets = GetReplicationTargets(out self);
if (replicationTargets != null)
{
log.Info("Ensuring default database {0} is replicated from {2} at {3}",string.IsNullOrWhiteSpace(database.Name) ? "Default" : database.Name, self.Id, self.InternalUrl);
if (!string.IsNullOrWhiteSpace(database.Name))
{
EnsureDatabaseExists(replicationTargets,database.Name);
}
var documentId = new ReplicationDocument().Id;
var replicationDocument = new ReplicationDocument()
{
Destinations =
replicationTargets
.Select(i => new ReplicationDestination() { Url = GetReplicationUrl(database.Name,i) })
.ToList()
};
database.Put(documentId, null, RavenJObject.FromObject(replicationDocument), new RavenJObject(), null);
}
}
示例8: DyanmicQueries
public DyanmicQueries()
{
db = new DocumentDatabase(new RavenConfiguration
{
DataDirectory = "raven.db.test.esent",
});
}
示例9: GeneralStorage
public GeneralStorage()
{
db = new DocumentDatabase(new RavenConfiguration
{
DataDirectory = "raven.db.test.esent",
});
}
示例10: Initialize
public override void Initialize(DocumentDatabase database)
{
settings = EncryptionSettingsManager.GetEncryptionSettingsForDatabase(database);
EncryptionSettingsManager.VerifyEncryptionKey(database, settings);
}
示例11: QueryingOnStaleIndexes
public QueryingOnStaleIndexes()
{
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = "raven.db.test.esent", RunInUnreliableYetFastModeThatIsNotSuitableForProduction = true });
db.PutIndex(new RavenDocumentsByEntityName().IndexName, new RavenDocumentsByEntityName().CreateIndexDefinition());
}
示例12: Munin
public Munin()
{
db = new DocumentDatabase(new RavenConfiguration
{
RunInMemory = true
});
}
示例13: BackupOperation
public BackupOperation(DocumentDatabase database, IPersistentSource persistentSource, string src, string to)
{
this.database = database;
this.persistentSource = persistentSource;
this.to = to.ToFullPath();
this.src = src.ToFullPath();
}
示例14: AfterBackupRestoreCanReadDocument
public void AfterBackupRestoreCanReadDocument()
{
db.Documents.Put("ayende", null, RavenJObject.Parse("{'email':'[email protected]'}"), new RavenJObject(), null);
db.Maintenance.StartBackup(BackupDir, false, new DatabaseDocument());
WaitForBackup(db, true);
db.Dispose();
IOExtensions.DeleteDirectory(DataDir);
MaintenanceActions.Restore(new RavenConfiguration(), new DatabaseRestoreRequest
{
BackupLocation = BackupDir,
DatabaseLocation = DataDir,
Defrag = true
}, s => { });
db = new DocumentDatabase(new RavenConfiguration { DataDirectory = DataDir });
var document = db.Documents.Get("ayende", null);
Assert.NotNull(document);
var jObject = document.ToJson();
Assert.Equal("[email protected]", jObject.Value<string>("email"));
}
示例15: IndexPropertyBatcher
public IndexPropertyBatcher(DocumentDatabase database, IndexedPropertiesSetupDoc setupDoc, string index, AbstractViewGenerator viewGenerator)
{
this.database = database;
this.setupDoc = setupDoc;
this.index = index;
this.viewGenerator = viewGenerator;
}