C#C
C#2y ago
Raki

How does option work in .net core

I have the below class here the contentfulclient base has a class called ContentfulClientBase which has a property called as contentfuloption with some property. I want to assign the value to one of the property. I have my own contentfuloption class which has some of the properties of ContentfulClientBase class contentfuloption. I want to pass my model value to contentfulclientbase class. But I don't know how to achieve it. When I use
_options = options.Value;
I get an error states type to type conversion is not possible.

Basically I want my baseclass property should get my value which I provide.

 public class ContentfulManagementService : ContentfulClientBase, IContentfulManagementService
    {
        private readonly ILogger<ContentfulManagementService> _logger;
        private readonly Models.ContentfulOptions _contentfulOptions;

        public ContentfulManagementService(
             HttpClient httpClient,
             ILogger<ContentfulManagementService> logger, IOptions<Models.ContentfulOptions> options)
        {
            _httpClient = httpClient;
            _logger = logger;
            _contentfulOptions = options.Value;
        }
}
Was this page helpful?