# Class NpgsqlFactory

Namespace
  Npgsql

Assembly
  Npgsql.dll

A factory to create instances of various Npgsql objects.

    [Serializable]
    public sealed class NpgsqlFactory : DbProviderFactory, IServiceProvider

Inheritance
  object
  DbProviderFactory
  NpgsqlFactory

Implements
  IServiceProvider

Inherited Members
  DbProviderFactory.CreateDataSourceEnumerator()
  DbProviderFactory.CanCreateDataSourceEnumerator
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.ReferenceEquals(object, object)
  object.ToString()

## Fields

### Instance

Gets an instance of the NpgsqlFactory. This can be used to retrieve strongly typed data objects.

    public static readonly NpgsqlFactory Instance

#### Field Value

NpgsqlFactory

## Properties

### CanCreateBatch

Gets a value that indicates whether this DbProviderFactory instance supports the DbBatch class.

    public override bool CanCreateBatch { get; }

#### Property Value

bool

  true if this instance supports the DbBatch class; otherwise, false. The default is false.

### CanCreateCommandBuilder

Specifies whether the specific DbProviderFactory supports the DbCommandBuilder class.

    public override bool CanCreateCommandBuilder { get; }

#### Property Value

bool

### CanCreateDataAdapter

Specifies whether the specific DbProviderFactory supports the DbDataAdapter class.

    public override bool CanCreateDataAdapter { get; }

#### Property Value

bool

## Methods

### CreateBatch()

Returns a new instance of the provider's class that implements the DbBatch class.

    public override DbBatch CreateBatch()

#### Returns

DbBatch

  A new instance of DbBatch.

### CreateBatchCommand()

Returns a new instance of the provider's class that implements the DbBatchCommand class.

    public override DbBatchCommand CreateBatchCommand()

#### Returns

DbBatchCommand

  A new instance of DbBatchCommand.

### CreateCommand()

Returns a strongly typed DbCommand instance.

    public override DbCommand CreateCommand()

#### Returns

DbCommand

### CreateCommandBuilder()

Returns a strongly typed DbCommandBuilder instance.

    public override DbCommandBuilder CreateCommandBuilder()

#### Returns

DbCommandBuilder

### CreateConnection()

Returns a strongly typed DbConnection instance.

    public override DbConnection CreateConnection()

#### Returns

DbConnection

### CreateConnectionStringBuilder()

Returns a strongly typed DbConnectionStringBuilder instance.

    public override DbConnectionStringBuilder CreateConnectionStringBuilder()

#### Returns

DbConnectionStringBuilder

### CreateDataAdapter()

Returns a strongly typed DbDataAdapter instance.

    public override DbDataAdapter CreateDataAdapter()

#### Returns

DbDataAdapter

### CreateDataSource(string)

Returns a new instance of the provider's class that implements the DbDataSource class, representing the database for the given connection string and ready to hand out connections to it.

    public override DbDataSource CreateDataSource(string connectionString)

#### Parameters

`connectionString` string

  The connection string of the database to be represented by this DbDataSource. The exact contents of the connection string depend on the specific data source for this connection.

#### Returns

DbDataSource

  A new instance of DbDataSource.

### CreateParameter()

Returns a strongly typed DbParameter instance.

    public override DbParameter CreateParameter()

#### Returns

DbParameter

### GetService(Type)

Gets the service object of the specified type.

    public object? GetService(Type serviceType)

#### Parameters

`serviceType` Type

  An object that specifies the type of service object to get.

#### Returns

object

  A service object of type serviceType, or null if there is no service object of type serviceType.