本文整理汇总了C#中ElasticsearchContext.GetDocumentAsync方法的典型用法代码示例。如果您正苦于以下问题:C# ElasticsearchContext.GetDocumentAsync方法的具体用法?C# ElasticsearchContext.GetDocumentAsync怎么用?C# ElasticsearchContext.GetDocumentAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElasticsearchContext
的用法示例。
在下文中一共展示了ElasticsearchContext.GetDocumentAsync方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDefaultContextGetEntityWhichDoesNotExist
public void TestDefaultContextGetEntityWhichDoesNotExist()
{
const int entityId = 3004;
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
var entityResult = context.GetDocumentAsync<SkillTestEntity>(entityId);
entityResult.Wait();
Assert.AreEqual(entityResult.Result.Status, HttpStatusCode.NotFound);
}
}
示例2: TestDefaultContextUpdateEntity
public void TestDefaultContextUpdateEntity()
{
const int entityId = 34;
SkillTestEntity resultfromGet;
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
// add a new entity
context.AddUpdateDocument(_entitiesForTests[entityId], entityId);
// Save to Elasticsearch
var ret = context.SaveChangesAsync();
Assert.AreEqual(ret.Result.Status, HttpStatusCode.OK);
// Get the entity
resultfromGet = context.GetDocumentAsync<SkillTestEntity>(entityId).Result.PayloadResult;
}
resultfromGet.Name = "updated";
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
// update entity
context.AddUpdateDocument(resultfromGet, entityId);
// Save to Elasticsearch
var ret = context.SaveChangesAsync();
Assert.AreEqual(ret.Result.Status, HttpStatusCode.OK);
// Get the entity
var readEntity = context.GetDocumentAsync<SkillTestEntity>(entityId).Result.PayloadResult;
Assert.AreEqual(readEntity.Name, resultfromGet.Name);
Assert.AreNotEqual(readEntity.Name, _entitiesForTests[entityId]);
}
}
示例3: TestDefaultContextGetEntityAsync
public void TestDefaultContextGetEntityAsync()
{
const int entityId = 34;
using (var context = new ElasticsearchContext(ConnectionString, _elasticsearchMappingResolver))
{
context.TraceProvider = new ConsoleTraceProvider();
context.AddUpdateDocument(_entitiesForTests[entityId], entityId);
// Save to Elasticsearch
var ret = context.SaveChangesAsync();
Assert.AreEqual(ret.Result.Status, HttpStatusCode.OK);
// Get the entity
var entityResult = context.GetDocumentAsync<SkillTestEntity>(entityId);
Assert.AreEqual(entityResult.Result.Status, HttpStatusCode.OK);
Assert.AreEqual(entityResult.Result.PayloadResult.Id, entityId);
Assert.IsNotNull(entityResult.Result.PayloadResult);
}
}