本文整理汇总了C#中IDatabaseCommands类的典型用法代码示例。如果您正苦于以下问题:C# IDatabaseCommands类的具体用法?C# IDatabaseCommands怎么用?C# IDatabaseCommands使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IDatabaseCommands类属于命名空间,在下文中一共展示了IDatabaseCommands类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: GenerateDocumentKey
public string GenerateDocumentKey(IDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
{
var shardId = shardedDocumentStore.ShardStrategy.ShardResolutionStrategy.MetadataShardIdFor(entity);
if (shardId == null)
throw new InvalidOperationException(string.Format(
"ShardResolutionStrategy.MetadataShardIdFor cannot return null. You must specify where to store the metadata documents for the entity type '{0}'.", entity.GetType().FullName));
MultiTypeHiLoKeyGenerator value;
if (generatorsByShard.TryGetValue(shardId, out value))
{
return value.GenerateDocumentKey(databaseCommands, conventions, entity);
}
lock (this)
{
if (generatorsByShard.TryGetValue(shardId, out value) == false)
{
value = new MultiTypeHiLoKeyGenerator(capacity);
generatorsByShard = new Dictionary<string, MultiTypeHiLoKeyGenerator>(generatorsByShard)
{
{shardId, value}
};
}
}
return value.GenerateDocumentKey(databaseCommands, conventions, entity);
}
开发者ID:925coder,项目名称:ravendb,代码行数:28,代码来源:ShardedHiloKeyGenerator.cs
示例2: HiLoKeyGenerator
/// <summary>
/// Initializes a new instance of the <see cref="HiLoKeyGenerator"/> class.
/// </summary>
public HiLoKeyGenerator(IDatabaseCommands databaseCommands, string tag, long capacity)
{
this.databaseCommands = databaseCommands;
this.tag = tag;
this.capacity = capacity;
current = 0;
}
开发者ID:seankearon,项目名称:ravendb,代码行数:10,代码来源:HiLoKeyGenerator.cs
示例3: GenerateDocumentKey
/// <summary>
/// Generates the document key.
/// </summary>
/// <param name="conventions">The conventions.</param>
/// <param name="entity">The entity.</param>
/// <returns></returns>
public string GenerateDocumentKey(IDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
{
var typeTagName = conventions.GetDynamicTagName(entity);
if (string.IsNullOrEmpty(typeTagName)) //ignore empty tags
return null;
var tag = conventions.TransformTypeTagNameToDocumentKeyPrefix(typeTagName);
HiLoKeyGenerator value;
if (keyGeneratorsByTag.TryGetValue(tag, out value))
return value.GenerateDocumentKey(databaseCommands, conventions, entity);
lock(generatorLock)
{
if (keyGeneratorsByTag.TryGetValue(tag, out value))
return value.GenerateDocumentKey(databaseCommands, conventions, entity);
value = new HiLoKeyGenerator(tag, capacity);
// doing it this way for thread safety
keyGeneratorsByTag = new Dictionary<string, HiLoKeyGenerator>(keyGeneratorsByTag)
{
{tag, value}
};
}
return value.GenerateDocumentKey(databaseCommands, conventions, entity);
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:31,代码来源:MultiTypeHiLoKeyGenerator.cs
示例4: HiLoKeyGenerator
public HiLoKeyGenerator(IDatabaseCommands commands, string tag, long capacity)
{
currentHi = 0;
this.commands = commands;
this.tag = tag;
this.capacity = capacity;
currentLo = capacity + 1;
}
开发者ID:kenegozi,项目名称:ravendb,代码行数:8,代码来源:HiLoKeyGenerator.cs
示例5: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
/// <param name="catalogToGetnIndexingTasksFrom">The catalog to get indexing tasks from.</param>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var tasks = catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>();
foreach (var task in tasks)
{
task.Execute(databaseCommands, conventions);
}
}
开发者ID:neiz,项目名称:ravendb,代码行数:12,代码来源:IndexCreation.cs
示例6: GetWindowsAuthDocument
static WindowsAuthDocument GetWindowsAuthDocument(IDatabaseCommands systemCommands)
{
var existing = systemCommands.Get("Raven/Authorization/WindowsSettings");
if (existing == null)
{
return new WindowsAuthDocument();
}
return existing
.DataAsJson
.JsonDeserialization<WindowsAuthDocument>();
}
开发者ID:cdnico,项目名称:docs.particular.net,代码行数:11,代码来源:UserCreation.cs
示例7: Execute
/// <summary>
/// Executes the index creation against the specified document database using the specified conventions
/// </summary>
public virtual void Execute(IDatabaseCommands databaseCommands, DocumentConvention documentConvention)
{
Conventions = documentConvention;
var transformerDefinition = CreateTransformerDefinition();
// This code take advantage on the fact that RavenDB will turn an index PUT
// to a noop of the index already exists and the stored definition matches
// the new definition.
databaseCommands.PutTransformer(TransformerName, transformerDefinition);
UpdateIndexInReplication(databaseCommands, documentConvention, (commands, url) =>
commands.PutTransformer(TransformerName, transformerDefinition));
}
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:15,代码来源:AbstractResultsTransformer.cs
示例8: WaitForDocument
private static void WaitForDocument(IDatabaseCommands commands, string expectedId)
{
for (int i = 0; i < RetriesCount; i++)
{
if (commands.Head(expectedId) != null)
break;
Thread.Sleep(100);
}
if(commands.Head(expectedId) == null)
throw new Exception("Document not replicated");
}
开发者ID:AleksanderGondek,项目名称:GUT_IronTester,代码行数:12,代码来源:Program.cs
示例9: AfterExecute
internal static void AfterExecute(IDatabaseCommands databaseCommands, string indexName, ScriptedIndexResults scripts)
{
var documentId = GetScriptedIndexResultsDocumentId(indexName);
scripts.Id = documentId;
var oldDocument = databaseCommands.Get(documentId);
var newDocument = RavenJObject.FromObject(scripts);
if (oldDocument != null && RavenJToken.DeepEquals(oldDocument.DataAsJson, newDocument))
return;
databaseCommands.Put(documentId, null, newDocument, null);
databaseCommands.ResetIndex(indexName);
}
开发者ID:j2jensen,项目名称:ravendb,代码行数:13,代码来源:AbstractScriptedIndexCreationTask.cs
示例10: SetupReplication
private static void SetupReplication(IDatabaseCommands source, params string[] urls)
{
source.Put(Constants.RavenReplicationDestinations,
null, new RavenJObject
{
{
"Destinations", new RavenJArray(urls.Select(url => new RavenJObject
{
{"Url", url}
}))
}
}, new RavenJObject());
}
开发者ID:AleksanderGondek,项目名称:GUT_IronTester,代码行数:13,代码来源:Program.cs
示例11: InvokePut
static bool InvokePut(IDatabaseCommands systemCommands, RavenJObject ravenJObject)
{
try
{
systemCommands.Put("Raven/Authorization/WindowsSettings", null, ravenJObject, new RavenJObject());
return true;
}
catch (ErrorResponseException exception)
{
if (exception.Message.Contains("Cannot setup Windows Authentication without a valid commercial license."))
{
throw new Exception("RavenDB requires a Commercial license to configure windows authentication. Please either install your RavenDB license or contact [email protected] if you need a copy of the RavenDB license.");
}
throw;
}
}
开发者ID:hanin,项目名称:NServiceBus.RavenDB,代码行数:16,代码来源:RavenUserInstaller.cs
示例12: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
try
{
var tasks = catalogToGetnIndexingTasksFrom
.GetExportedValues<AbstractIndexCreationTask>()
.ToList();
var indexesToAdd = tasks
.Select(x => new IndexToAdd
{
Definition = x.CreateIndexDefinition(),
Name = x.IndexName,
Priority = x.Priority ?? IndexingPriority.Normal
})
.ToArray();
databaseCommands.PutIndexes(indexesToAdd);
foreach (var task in tasks)
task.AfterExecute(databaseCommands, conventions);
}
// For old servers that don't have the new entrypoint for executing multiple indexes
catch (Exception)
{
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.Execute(databaseCommands, conventions);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(databaseCommands, conventions);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
开发者ID:nwendel,项目名称:ravendb,代码行数:50,代码来源:IndexCreation.cs
示例13: NextId
///<summary>
/// Create the next id (numeric)
///</summary>
public long NextId(IDatabaseCommands commands)
{
while (true)
{
var myRange = Range; // thread safe copy
var current = Interlocked.Increment(ref myRange.Current);
if (current <= myRange.Max)
return current;
lock (generatorLock)
{
if (Range != myRange)
// Lock was contended, and the max has already been changed. Just get a new id as usual.
continue;
Range = GetNextRange(commands);
}
}
}
开发者ID:samueldjack,项目名称:ravendb,代码行数:23,代码来源:HiLoKeyGenerator.cs
示例14: CreateIndexes
/// <summary>
/// Creates the indexes found in the specified catalog
/// </summary>
public static void CreateIndexes(ExportProvider catalogToGetnIndexingTasksFrom, IDatabaseCommands databaseCommands, DocumentConvention conventions)
{
var indexCompilationExceptions = new List<IndexCompilationException>();
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractIndexCreationTask>())
{
try
{
task.Execute(databaseCommands, conventions);
}
catch (IndexCompilationException e)
{
indexCompilationExceptions.Add(new IndexCompilationException("Failed to compile index name = " + task.IndexName, e));
}
}
foreach (var task in catalogToGetnIndexingTasksFrom.GetExportedValues<AbstractTransformerCreationTask>())
{
task.Execute(databaseCommands, conventions);
}
if (indexCompilationExceptions.Any())
throw new AggregateException("Failed to create one or more indexes. Please see inner exceptions for more details.", indexCompilationExceptions);
}
开发者ID:felipeleusin,项目名称:ravendb,代码行数:27,代码来源:IndexCreation.cs
示例15: PutDocument
private void PutDocument(IDatabaseCommands databaseCommands,JsonDocument document)
{
databaseCommands.Put(HiLoDocumentKey, document.Etag,
document.DataAsJson,
document.Metadata);
}
开发者ID:samueldjack,项目名称:ravendb,代码行数:6,代码来源:HiLoKeyGenerator.cs
示例16: MultiTypeHiLoKeyGenerator
/// <summary>
/// Initializes a new instance of the <see cref="MultiTypeHiLoKeyGenerator"/> class.
/// </summary>
public MultiTypeHiLoKeyGenerator(IDatabaseCommands databaseCommands, int capacity)
{
this.databaseCommands = databaseCommands;
this.capacity = capacity;
}
开发者ID:jtmueller,项目名称:ravendb,代码行数:8,代码来源:MultiTypeHiLoKeyGenerator.cs
示例17: GenerateDocumentKey
public string GenerateDocumentKey(string dbName, IDatabaseCommands databaseCommands, DocumentConvention conventions, object entity)
{
var multiTypeHiLoKeyGenerator = generators.GetOrAdd(dbName ?? Constants.SystemDatabase, s => new MultiTypeHiLoKeyGenerator(capacity));
return multiTypeHiLoKeyGenerator.GenerateDocumentKey(databaseCommands, conventions, entity);
}
开发者ID:WimVergouwe,项目名称:ravendb,代码行数:5,代码来源:MultiDatabaseHiLoGenerator.cs
示例18: SetupCommands
private static IDatabaseCommands SetupCommands(IDatabaseCommands databaseCommands, string database, ICredentials credentialsForSession, OpenSessionOptions options)
{
if (database != null)
databaseCommands = databaseCommands.ForDatabase(database);
if (credentialsForSession != null)
databaseCommands = databaseCommands.With(credentialsForSession);
if (options.ForceReadFromMaster)
databaseCommands.ForceReadFromMaster();
return databaseCommands;
}
开发者ID:heinnge,项目名称:ravendb,代码行数:10,代码来源:DocumentStore.cs
示例19: WaitForDocument
protected virtual void WaitForDocument(IDatabaseCommands databaseCommands, string id)
{
var done = SpinWait.SpinUntil(() =>
{
// We expect to get the doc from the <system> database
var doc = databaseCommands.Get(id);
return doc != null;
}, TimeSpan.FromMinutes(5));
if (!done) throw new Exception("WaitForDocument failed");
}
开发者ID:hero106wen,项目名称:ravendb,代码行数:11,代码来源:RavenTestBase.cs
示例20: WaitForRestore
protected void WaitForRestore(IDatabaseCommands databaseCommands)
{
var systemDatabaseCommands = databaseCommands.ForSystemDatabase(); // need to be sure that we are checking system database
var failureMessages = new[]
{
"Esent Restore: Failure! Could not restore database!",
"Error: Restore Canceled",
"Restore Operation: Failure! Could not restore database!"
};
var restoreFinishMessages = new[]
{
"The new database was created",
"Esent Restore: Restore Complete",
"Restore ended but could not create the datebase document, in order to access the data create a database with the appropriate name",
};
var done = SpinWait.SpinUntil(() =>
{
// We expect to get the doc from the <system> database
var doc = systemDatabaseCommands.Get(RestoreStatus.RavenRestoreStatusDocumentKey);
if (doc == null)
return false;
var status = doc.DataAsJson.Deserialize<RestoreStatus>(new DocumentConvention());
if (failureMessages.Any(status.Messages.Contains))
throw new InvalidOperationException("Restore failure: " + status.Messages.Aggregate(string.Empty, (output, message) => output + (message + Environment.NewLine)));
return restoreFinishMessages.Any(status.Messages.Contains);
}, TimeSpan.FromMinutes(5));
if (!done) throw new Exception("WaitForRestore failed");
}
开发者ID:hero106wen,项目名称:ravendb,代码行数:36,代码来源:RavenTestBase.cs
注:本文中的IDatabaseCommands类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论