-1

I'm new to C# and NEST API. I have done few projects using it but I'm not clear why the class_name / POCO name mentioned in every NEST Query.

Consider the following queries,

 - client.DeleteAsync<class_name>(id)
 - client.Delete<class_name>(id)
 - client.Search<class_name>(id)

What does the class_name have to do anything with the query? Please explain.

Regolith
  • 2,944
  • 9
  • 33
  • 50
samuellawrentz
  • 1,662
  • 11
  • 23
  • It's called Generic, and it's a way to avoid having the same code repeated for every class. Without generics, you would have: client.DeleteSomething and client.DeleteSomethingElse and client.DeleteMyClass etc... Have a search for C# generic you'll find plenty of information – Etienne Aug 04 '17 at 05:38
  • 1
    Take a look at the documentation for NEST, as I think it answers your question: https://www.elastic.co/guide/en/elasticsearch/client/net-api/current/nest.html – Russ Cam Aug 04 '17 at 05:43

1 Answers1

0

class_name is your poco class name.

which contain all get or set methods/fields name.

for <T>.

It's dynamic or generic type parameter.

You can pass any datatype into that.

refer this link for more clarification.

Click here

Kalpesh Boghara
  • 418
  • 3
  • 22
  • 1
    I think the OP was more asking _why_ methods in NEST take a generic type parameter, as opposed to _what_ a generic type parameter is. – Russ Cam Aug 04 '17 at 07:16