# Enterprise Knowledge Graph v1 API - Class ServiceCollectionExtensions (1.0.0-beta05)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.0.0-beta05 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/latest/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [1.0.0-beta04](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/1.0.0-beta04/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)

    public static class ServiceCollectionExtensions

Reference documentation and code samples for the Enterprise Knowledge Graph v1 API class ServiceCollectionExtensions.

Static class to provide extension methods to configure API clients.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ServiceCollectionExtensions

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Microsoft.Extensions.DependencyInjection](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/latest/Microsoft.Extensions.DependencyInjection)

## Assembly

Google.Cloud.EnterpriseKnowledgeGraph.V1.dll

## Methods

### AddEnterpriseKnowledgeGraphServiceClient(IServiceCollection, Action\<EnterpriseKnowledgeGraphServiceClientBuilder\>)

    public static IServiceCollection AddEnterpriseKnowledgeGraphServiceClient(this IServiceCollection services, Action<EnterpriseKnowledgeGraphServiceClientBuilder> action = null)

Adds a singleton [EnterpriseKnowledgeGraphServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/latest/Google.Cloud.EnterpriseKnowledgeGraph.V1.EnterpriseKnowledgeGraphServiceClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/latest/Google.Cloud.EnterpriseKnowledgeGraph.V1.EnterpriseKnowledgeGraphServiceClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddEnterpriseKnowledgeGraphServiceClient(IServiceCollection, Action\<IServiceProvider, EnterpriseKnowledgeGraphServiceClientBuilder\>)

    public static IServiceCollection AddEnterpriseKnowledgeGraphServiceClient(this IServiceCollection services, Action<IServiceProvider, EnterpriseKnowledgeGraphServiceClientBuilder> action)

Adds a singleton [EnterpriseKnowledgeGraphServiceClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/latest/Google.Cloud.EnterpriseKnowledgeGraph.V1.EnterpriseKnowledgeGraphServiceClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.EnterpriseKnowledgeGraph.V1/latest/Google.Cloud.EnterpriseKnowledgeGraph.V1.EnterpriseKnowledgeGraphServiceClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |