Dean
Dean

Reputation: 887

NEST trying to convert enum to string

Good day:

I have the following code however, I'm getting the following error:

return new ConnectionSettings(pool, (s, v) => s.Converters.Add(new StringEnumConverter())).DefaultIndex(index)
                .DefaultMappingFor<Document>(m => m.IndexName(index).TypeName("doc"))
                .DefaultMappingFor<FacilityType>(m => m.IndexName(index).TypeName("doc"))
                .DefaultMappingFor<Facility>(m => m.IndexName(index).TypeName("doc").RelationName("parent"))
                .BasicAuthentication(ConfigurationManager.AppSettings["ElasticUser"], ConfigurationManager.AppSettings["ElasticPassword"]);

Severity Code Description Project File Line Suppression State Error CS1061 'IElasticsearchSerializer' does not contain a definition for 'Converters' and no extension method 'Converters' accepting a first argument of type 'IElasticsearchSerializer' could be found (are you missing a using directive or an assembly reference?) iserro.API C:\Users\IEUser\source\repos\iserro-api\iserro.API\App_Start\DiContainerConfig.cs 131 Active

Upvotes: 0

Views: 1306

Answers (1)

Russ Cam
Russ Cam

Reputation: 125498

I think the error message clearly indicates what the problem is.

It looks like you'd like IElasticsearchSerializer to be a concrete instance that exposes a Converters property, which the JsonNetSerializer type in the Nest.JsonNetSerializer NuGet package exposes so you can hook it up and add custom converters.

Upvotes: 1

Related Questions