【发布时间】:2021-05-19 10:17:52
【问题描述】:
当我运行这段代码时:
var result = _client.Index<EntityType>(item, i => i.Index(n));
我收到此错误:
发生异常:CLR/System.StackOverflowException 未处理 'System.StackOverflowException' 类型的异常发生在 Elasticsearch.Net.dll
完整方法:
public bool Index<EntityType>(EntityType item, int attempt = 0) where EntityType : class, IDomainEntity<int>
{
const int maxRetries = 5;
if (item == null)
{
return false;
}
var type = item.GetType();
var attributes = type.CustomAttributes;
string n = "";
foreach (var attribute in attributes)
{
foreach (var arg in attribute.NamedArguments)
{
if (arg.MemberName == "RelationName")
{
n = arg.TypedValue.Value.ToString().ToLower();
}
}
}
var result = _client.Index<EntityType>(item, i => i.Index(n));
if (!CheckResponse(result) && attempt < maxRetries)
{
RefreshClient<EntityType>();
attempt++;
return Index(item, attempt);
}
RefreshClient<EntityType>();
return result.IsValid;
}
【问题讨论】:
-
属性
Id的IdType是什么? -
@RussCam int。我也使用泛型来允许字符串 id。
-
啊抱歉,我错过了(深夜:))你有一个完整的可复制的例子可以分享(在这里或作为要点)?
-
@RussCam 我实际上认为它可能与您的other answer 相同,在意识到您已回答之前,我已将其链接到我的问题中。
-
这也是我的怀疑
标签: asp.net-core elasticsearch .net-core nest