Reputation: 4669
When I have an explicitly typed object, I have no problems indexing. For example,
EventObject e;
IElasticClient client;
client.Index(e); // perfectly valid
However, I have a class where the type is generic. This is my class
class FantasticClass<INDEXCLASS>
{
IElasticClient client;
public FantasticClass(IElasticClient c)
{
client = c;
}
public INDEXCLASS Add(INDEXCLASS entity)
{
client.Index(entity); // can't compile!
// or
client.Index<INDEXCLASS>(entity); // can't compile!
}
}
How do you index with Nest when the class type is inferred?
Upvotes: 0
Views: 227
Reputation: 2430
The issues with it not compiling are due to the class missing the declaration of what type INDEXCLASS
is this should resolve that error:
class FantasticClass<INDEXCLASS> where INDEXCLASS : class
Also the Add
method has a return type of INDEXCLASS however nothing is returning in the method. Either change it to void
or return the entity
variable after it has been indexed.
Upvotes: 1