• NeonSDK
  • NeonKUBE
Search Results for

    Show / Hide Table of Contents
    • Neon
      • Build
    • Neon.Blazor
      • BlazorHelper
      • BodyOutlet
      • ClientRenderContext
      • DOMRectReadOnly
      • EventHandlers
      • FileDownloader
      • HtmlElement
      • IRenderContext
      • IntersectionChangedEventArgs
      • IntersectionObserver
      • IntersectionObserverContext
      • MobileDetector
      • NeonBlazorExtensions
      • ServerRenderContext
      • SwipeDirection
      • SwipeHandler
    • Neon.Blazor.Analyzers
      • SvgGenerator
      • SvgGenerator.Svg
    • Neon.BuildInfo
      • ThisAssembly
      • ThisAssembly.Git
      • ThisAssembly.Git.BaseVersion
      • ThisAssembly.Git.SemVer
    • Neon.CSharp
      • CSharpHelper
      • CompilerErrorException
      • MetadataReferences
    • Neon.Cassandra
      • KeyspaceStatus
      • RowSetExtensions
      • SchemaManager
      • SchemaManagerException
      • SchemaStatus
      • SessionExtensions
    • Neon.Collections
      • ArgDictionary
      • Bits
      • IObjectDictionary
      • NiceDictionary<TKey, TValue>
      • ObjectDictionary
    • Neon.Common
      • AppDomainExtensions
      • Block
      • BlockArray
      • ByteEncoding
      • ByteUnits
      • CommandLine
      • CommandLine.OptionDefinition
      • CommandLine.Redactor
      • CpuArchitecture
      • Credentials
      • DateTimeExtensions
      • EnumExtensions
      • EnvironmentParser
      • EnvironmentParser.Parser<T>
      • EnvironmentParser.Validator<T>
      • EnvironmentParser.VariableSource
      • ExceptionExtensions
      • ExecuteException
      • ExecuteResponse
      • GlobPattern
      • HexDumpOption
      • HttpClientExtensions
      • HttpResponseMessageExtensions
      • IEnumerableExtensions
      • ILabeled
      • IOExtensions
      • IServiceContainer
      • IStaticDirectoryExtensions
      • LabelSelector
      • LabelSelectorOptions
      • LabelSelector<TItem>
      • NeonAssemblyExtensions
      • NeonExtendedHelper
      • NeonHelper
      • NetFramework
      • NewtonsoftExtensions
      • NotReadyException
      • ProcessExtensions
      • ProgramEntrypoint
      • ProgramEntrypointAsync
      • ProgramExitException
      • ProgramRunner
      • RandomExtensions
      • ReflectionExtensions
      • SemanticVersion
      • ServiceContainer
      • StaticZipOptions
      • StringBuilderExtensions
      • StringExtensions
      • Stub
      • Stub.Value
      • TaskExtensions
      • TimeSpanExtensions
      • ToolException
      • TriState
      • WeakEventController
      • WindowsEdition
      • WindowsFeatureStatus
      • YamlDotNetExtensions
    • Neon.Cryptography
      • AesCipher
      • CryptoExtensions
      • CryptoHelper
      • NeonVault
      • Wildcard
    • Neon.Csv
      • CsvReader
      • CsvTableReader
      • CsvTableWriter
      • CsvWriter
    • Neon.Data
      • DateTimeJsonConverter
      • DateTimeOffsetJsonConverter
      • IEnhancedJsonConverter
      • IGeneratedServiceClient
      • IPersistableType
      • IPersistableType<T>
      • IRoundtripData
      • IntegerEnumConverter<TEnum>
      • NotifyPropertyChanged
      • RoundtripDataFactory
      • RoundtripDataHelper
      • TimeSpanJsonConverter
      • VersionJsonConverter
    • Neon.Deployment
      • AwsCli
      • DeploymentException
      • DeploymentHelper
      • DownloadManifest
      • DownloadPart
      • DownloadProgressDelegate
      • DownloadProgressType
      • GitHub
      • GitHubActionsApi
      • GitHubPackage
      • GitHubPackageApi
      • GitHubPackageType
      • GitHubPackageVersion
      • GitHubPackageVisibility
      • GitHubReleaseApi
      • GitHubRepoPath
      • GitHubTagApi
      • IProfileClient
      • IProfileRequest
      • IProfileResponse
      • MaintainerProfile
      • NotifyClient
      • OnePassword
      • OnePasswordException
      • ProfileException
      • ProfileHandlerResult
      • ProfileRequest
      • ProfileResponse
      • ProfileServer
      • ProfileStatus
      • XenServer
    • Neon.Deployment.CodeSigning
      • AzureProfile
      • CodeSigner
      • UsbTokenProfile
    • Neon.Diagnostics
      • AssertException
      • ConfigExtensions
      • ConsoleJsonLogExporter
      • ConsoleJsonLogExporterOptions
      • ConsoleTextLogExporter
      • ConsoleTextLogExporterOptions
      • ExceptionInfo
      • FileLogExporter
      • FileLogExporterFormat
      • FileLogExporterOptions
      • LogAsTraceProcessor
      • LogAsTraceProcessorOptions
      • LogAttributeNames
      • LogAttributes
      • LogEvent
      • LogEventInterceptor
      • LoggerExtensions
      • NullLogger
      • TelemetryHub
      • TelemetrySpanEventNames
      • TelemetrySpanExtensions
    • Neon.Docker
      • DockerClient
      • DockerNetwork
      • DockerNetworkContainer
      • DockerNetworkIpam
      • DockerNode
      • DockerNodeManagerStatus
      • DockerResponse
      • DockerSettings
      • DockerVolume
      • NetworkCreateResponse
      • ServiceBindOptions
      • ServiceConfig
      • ServiceContainerSpec
      • ServiceCredentialSpec
      • ServiceDetails
      • ServiceDiscreteResourceSpec
      • ServiceDnsConfig
      • ServiceEndpoint
      • ServiceEndpointMode
      • ServiceEndpointPortConfig
      • ServiceEndpointSpec
      • ServiceFile
      • ServiceGenericResources
      • ServiceGlobalSchedulingMode
      • ServiceHealthCheck
      • ServiceIsolationMode
      • ServiceListResponse
      • ServiceLogDriver
      • ServiceMode
      • ServiceMount
      • ServiceMountBindPropagation
      • ServiceMountConsistency
      • ServiceMountType
      • ServiceNamedResourceSpec
      • ServiceNetwork
      • ServicePlacement
      • ServicePlacementPreferences
      • ServicePlacementSpreadSettings
      • ServicePlatform
      • ServicePortMode
      • ServicePortProtocol
      • ServicePrivileges
      • ServiceReplicatedSchedulingMode
      • ServiceResourceSettings
      • ServiceResources
      • ServiceRestartCondition
      • ServiceRestartPolicy
      • ServiceRollbackConfig
      • ServiceRollbackFailureAction
      • ServiceRollbackOrder
      • ServiceSELinuxContext
      • ServiceSchedulingMode
      • ServiceSecret
      • ServiceSpec
      • ServiceTaskTemplate
      • ServiceTmpfsOptions
      • ServiceUpdateConfig
      • ServiceUpdateFailureAction
      • ServiceUpdateOrder
      • ServiceUpdateState
      • ServiceUpdateStatus
      • ServiceVersion
      • ServiceVirtualIP
      • ServiceVolumeDriverConfig
      • ServiceVolumeOptions
      • VolumeListResponse
    • Neon.GitHub
      • GitExtensions
      • GitHubCredentials
      • GitHubRepo
      • LocalRepoApi
      • NoLocalRepositoryException
      • RemoteRepoApi
      • RemoteRepoBranchApi
      • RemoteRepoIssueApi
      • RemoteRepoIssueCommentApi
      • RemoteRepoPath
      • RemoteRepoReleaseApi
      • RemoteRepoTagApi
    • Neon.HyperV
      • HyperVClient
      • HyperVDriverType
      • HyperVException
      • NetAdapter
      • VirtualDrive
      • VirtualIPAddress
      • VirtualMachine
      • VirtualMachineNetworkAdapter
      • VirtualMachineState
      • VirtualNat
      • VirtualSwitch
      • VirtualSwitchType
    • Neon.IO
      • BlockStream
      • FixedLengthStream
      • IStaticDirectory
      • IStaticFile
      • LineEnding
      • LinuxPath
      • LinuxPermissions
      • PreprocessReader
      • RelayStream
      • StaticDirectoryBase
      • StaticFileBase
      • SubStream
      • TempFile
      • TempFolder
    • Neon.JsonConverters
      • JsonDateTimeConverter
      • JsonGenericConverter<T>
      • JsonNullableDateTimeConverter
    • Neon.ModelGen
      • ActionResult<T>
      • ApiVersion
      • ApiVersionAttribute
      • BodyStreamAttribute
      • ControllerValidationAttribute
      • DataModelAttribute
      • EnumMember
      • FromBodyAttribute
      • FromHeaderAttribute
      • FromQueryAttribute
      • FromRouteAttribute
      • GeneratedClientAttribute
      • GeneratedMethodAttribute
      • GeneratedParamAttribute
      • HashSourceAttribute
      • HttpAttribute
      • HttpDeleteAttribute
      • HttpGetAttribute
      • HttpHeadAttribute
      • HttpOptionsAttribute
      • HttpPatchAttribute
      • HttpPostAttribute
      • HttpPutAttribute
      • IActionResult
      • ModelGenerator
      • ModelGeneratorOutput
      • ModelGeneratorSettings
      • NoCodeGenAttribute
      • NoControllerValidationAttribute
      • PassAs
      • PersistableAttribute
      • PersistableKeyAttribute
      • RouteAttribute
      • ServiceModelAttribute
      • TargetAttribute
      • UxFrameworks
    • Neon.Net
      • HttpApiException
      • HttpException
      • JsonClient
      • JsonClientPayload
      • JsonResponse
      • Jwt
      • LocalHostSection
      • NetConst
      • NetHelper
      • NetworkCidr
      • NetworkConfiguration
      • NetworkException
      • NetworkPorts
      • Pinger
      • ReachableHost
      • ReachableHostMode
      • StreamDocument
    • Neon.Postgres
      • ConnectionExtensions
      • DatabaseStatus
      • PreparedCommand
      • ReaderAsyncEnumerator
      • ReaderEnumerator
      • ReaderExtensions
      • SchemaManager
      • SchemaManagerException
      • SchemaStatus
    • Neon.Retry
      • ExponentialRetryPolicy
      • IRetryPolicy
      • LinearRetryPolicy
      • NoRetryPolicy
      • RetryPolicy
      • RetryPolicyBase
      • RetryTransientArgs
      • TransientDetector
      • TransientException
    • Neon.Roslyn
      • DisplayFormat
      • DocumentationComment
      • DocumentationItem
      • MetadataLoadContext
      • RoslynAssembly
      • RoslynConstructorInfo
      • RoslynCustomAttributeData
      • RoslynExtensions
      • RoslynFieldInfo
      • RoslynMethodInfo
      • RoslynParameterInfo
      • RoslynPropertyInfo
      • RoslynType
      • SharedUtilities
    • Neon.Roslyn.Xunit
      • AdditionalSourceText
      • CompilationOptions
      • CompilationOptionsProvider
      • TestCompilation
      • TestCompilationAssertions
      • TestCompilationBuilder
      • TestCompilationBuilderExtensions
      • TestCompilationExtensions
    • Neon.SSH
      • CommandBundle
      • CommandFile
      • CommandResponse
      • HostFolders
      • IBashCommandFormatter
      • ILinuxSshProxy
      • LinuxDiskInfo
      • LinuxDiskPartition
      • LinuxSshProxy
      • LinuxSshProxy<TMetadata>
      • NamespaceDoc
      • RemoteCommandException
      • RunOptions
      • SshCredentials
      • SshExtensions
      • SshProxyException
    • Neon.Service
      • LogMetricsProcessor
      • MetricsMode
      • MetricsOptions
      • NeonService
      • NeonServiceOptions
      • NeonServiceStatus
      • OtelConfigExtensions
      • OtlpCollectorChecker
      • ProcessTerminator
      • ServiceApiContact
      • ServiceApiInfo
      • ServiceApiLicense
      • ServiceDependencies
      • ServiceDescription
      • ServiceEndpoint
      • ServiceEndpointProtocol
      • ServiceEndpoints
      • ServiceMap
    • Neon.SignalR
      • DependencyInjectionExtensions
      • DnsCache
      • GroupAction
      • GroupCommand
      • IDnsCache
      • Invocation
      • NatsHubLifetimeManager<THub>
      • ProxyConfig
      • ServiceCollectionExtensions
      • ServiceDiscovey
      • SignalrProxyMiddleware
      • SignalrProxyMiddlewareExtensions
      • TracerProviderBuilderExtensions
    • Neon.Tailwind
      • ClickOffEventHandler
      • ComponentEventArgs<TSender>
      • ComponentEventArgs<TSender, TEventArgs>
      • DisclosureState
      • EventHandlerComponentBase<TComponent>
      • HeadlessButton
      • HeadlessDialog
      • HeadlessDialogPanel
      • HeadlessDisclosure
      • HeadlessDisclosureButton
      • HeadlessDisclosurePanel
      • HeadlessListboxButton<TValue>
      • HeadlessListboxLabel<TValue>
      • HeadlessListboxOption<TValue>
      • HeadlessListboxOptions<TValue>
      • HeadlessListbox<TValue>
      • HeadlessMenu
      • HeadlessMenuButton
      • HeadlessMenuItem
      • HeadlessMenuItems
      • HeadlessSwitch
      • HeadlessSwitchGroup
      • HeadlessSwitchLabel
      • IPortalBinder
      • KeyDownEventHandler
      • KeyboardKey
      • ListboxFocus
      • ListboxState
      • MenuFocus
      • MenuState
      • Portal
      • PortalBinder
      • PortalContent
      • SearchAssistant
      • TailwindExtensions
      • Transition
      • TransitionGroup
      • TransitionState
    • Neon.Tasks
      • Async
      • AsyncAutoResetEvent
      • AsyncManualResetEvent
      • AsyncMutex
      • AsyncPeriodicTask
      • AsyncReaderWriterLock
      • AsyncReentrantMutex
      • AsyncTimer
      • IAsyncFuture
      • IAsyncFuture<T>
      • NonDisposableTask
      • NonDisposableTask<T>
      • SyncContext
      • SyncContextMode
    • Neon.Temporal
      • ActivityHelper
      • ActivityLogEnricher
      • TemporalEnricherTagNames
      • WorkflowLogEnricher
    • Neon.Time
      • GatedTimer
      • GoDuration
      • PolledTimer
      • RecurringTimer
      • RecurringTimerType
      • SysTime
      • TimeOfDay
    • Neon.WSL
      • Wsl2Proxy
    • Neon.Web
      • AesProtector
      • DataProtectionExtensions
      • NeonController
      • NeonControllerBase
      • RoundTripJsonInputFormatter
      • RoundTripJsonOutputFormatter
      • TracerProviderBuilderExtensions
      • WebHelper
    • Neon.WinTTY
      • ConsoleTTY
    • Neon.Windows
      • MEMORYSTATUSEX
      • PowerShellException
      • Win32
    • Neon.XenServer
      • IXenClient
      • XenClient
      • XenClient.MachineOperations
      • XenClient.StorageOperations
      • XenClient.TemplateOperations
      • XenException
      • XenHostInfo
      • XenObject
      • XenResponse
      • XenStorageRepository
      • XenTempIso
      • XenTemplate
      • XenVirtualDisk
      • XenVirtualMachine
      • XenVmPowerState
    • Neon.Xunit
      • AnsiblePlayResults
      • AnsiblePlayer
      • AnsibleTaskResult
      • AspNetFixture
      • BasicFixture
      • CodeFixture
      • CollectionComparer<T>
      • ComposedFixture
      • ContainerFixture
      • ContainerLimits
      • DockerComposeFixture
      • DockerFixture
      • DockerFixture.ConfigInfo
      • DockerFixture.ContainerInfo
      • DockerFixture.NetworkInfo
      • DockerFixture.SecretInfo
      • DockerFixture.ServiceInfo
      • DockerFixture.StackDefinition
      • DockerFixture.StackInfo
      • DockerFixture.StackService
      • EnvironmentFixture
      • HostsFixture
      • ITestFixture
      • IncompatibleServiceException
      • MaintainerFactAttribute
      • MaintainerTheoryAttribute
      • MockHttpServer
      • MockHttpServerExtensions
      • NatsFixture
      • NatsStreamingFixture
      • NeonServiceFixture<TService>
      • PlatformFactAttribute
      • RepeatAttribute
      • TargetPlatforms
      • TestArea
      • TestCollection
      • TestContext
      • TestFixture
      • TestFixtureStatus
      • TestHelper
      • TestHttpClient
      • TestOutputWriter
      • TestTrait
      • XunitExtensions
    • Neon.Xunit.YugaByte
      • YugaByteFixture
    • Neon.YugaByte
      • YugaByteHelper

    Class ConnectionExtensions

    Extends Npgsql.NpgsqlConnection with useful methods.

    Inheritance
    object
    ConnectionExtensions
    Namespace: Neon.Postgres
    Assembly: Neon.Postgres.dll
    Syntax
    public static class ConnectionExtensions

    Methods

    ExecuteBatch(NpgsqlConnection, string, NpgsqlTransaction)

    Executes a batch of SQL commands saeparated by lines including go separators. This works like Microsoft SQL server related tools.

    Declaration
    public static void ExecuteBatch(this NpgsqlConnection connection, string batchText, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string batchText

    The SQL commands possibly separated by go lines.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Remarks

    It's often necessary to execute a sequence of SQL commands that depend on each other. One example is a command that creates a table followed by commands that write rows. You might think that you could achieve this by executing the following as one command:

    CREATE TABLE my_table (name text);
    INSERT INTO my_table (name) values ('Jack');
    INSERT INTO my_table (name) values ('Jill');

    but this won't actually work because the database generates a query plan for the entire command and when it does this and sees the inserts into [my_table] but the table doesn't actually exist at the time the query plan is being created. So the command will fail.

    What you really need to do is create the table first as a separate command and then do the inserts as one or more subsequent commands. This is not terribly convenient so we've introduced the concept of a batch of commands via this method. Here's what this would look like:

    CREATE TABLE my_table (name text);
    go
    INSERT INTO my_table (name) values ('Jack');
    INSERT INTO my_table (name) values ('Jill');

    See how the go line separates the table creation from the inserts. This method will split the batchText into separate commands on any go lines and then execute these commands in order.

    note

    go is case insensitive and any leading or trailing space on the line will be ignored.

    ExecuteBatchAsync(NpgsqlConnection, string, CancellationToken, NpgsqlTransaction)

    Asynchronously a batch of SQL commands saeparated by lines including go separators. This works like Microsoft SQL server related tools.

    Declaration
    public static Task ExecuteBatchAsync(this NpgsqlConnection connection, string batchText, CancellationToken cancellationToken = default, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string batchText

    The SQL commands possibly separated by go lines.

    CancellationToken cancellationToken

    Optional cancellation token.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    Task

    The tracking Task.

    Remarks

    It's often necessary to execute a sequence of SQL commands that depend on each other. One example is a command that creates a table followed by commands that write rows. You might think that you could achieve this by executing the following as one command:

    CREATE TABLE my_table (name text);
    INSERT INTO my_table (name) values ('Jack');
    INSERT INTO my_table (name) values ('Jill');

    but this won't actually work because the database generates a query plan for the entire command and when it does this and sees the inserts into [my_table] but the table doesn't actually exist at the time the query plan is being created. So the command will fail.

    What you really need to do is create the table first as a separate command and then do the inserts as one or more subsequent commands. This is not terribly convenient so we've introduced the concept of a batch of commands via this method. Here's what this would look like:

    CREATE TABLE my_table (name text);
    go
    INSERT INTO my_table (name) values ('Jack');
    INSERT INTO my_table (name) values ('Jill');

    See how the go line separates the table creation from the inserts. This method will split the batchText into separate commands on any go lines and then execute these commands in order.

    note

    go is case insensitive and any leading or trailing space on the line will be ignored.

    ExecuteNonQuery(NpgsqlConnection, string, NpgsqlTransaction)

    Executes a SQL command that does not perform a query.

    Declaration
    public static int ExecuteNonQuery(this NpgsqlConnection connection, string cmdText, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string cmdText

    The SQL command.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    int

    The number of rows impacted.

    Remarks
    note

    Although this method is convienent, consider explictly creating and preparing Npgsql.NpgsqlCommand for frequently executed commands for better performance.

    ExecuteNonQueryAsync(NpgsqlConnection, string, CancellationToken, NpgsqlTransaction)

    Asynchronously executes a SQL command that does not perform a query.

    Declaration
    public static Task<int> ExecuteNonQueryAsync(this NpgsqlConnection connection, string cmdText, CancellationToken cancellationToken = default, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string cmdText

    The SQL command.

    CancellationToken cancellationToken

    Optional cancellation token.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    Task<int>

    The number of rows impacted.

    Remarks
    note

    Although this method is convienent, consider explictly creating and preparing Npgsql.NpgsqlCommand for frequently executed commands for better performance.

    ExecuteReader(NpgsqlConnection, string, CommandBehavior, NpgsqlTransaction)

    Executes a SQL query and returns the data reader to be used to process the results.

    Declaration
    public static NpgsqlDataReader ExecuteReader(this NpgsqlConnection connection, string cmdText, CommandBehavior behavior = CommandBehavior.Default, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string cmdText

    The SQL command.

    CommandBehavior behavior

    Optionally specifies the command behavior.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    NpgsqlDataReader

    The Npgsql.NpgsqlDataReader.

    Remarks
    note

    Although this method is convenient, consider explictly creating and preparing Npgsql.NpgsqlCommand for frequently executed commands for better performance.

    ExecuteReaderAsync(NpgsqlConnection, string, CommandBehavior, CancellationToken, NpgsqlTransaction)

    Asynchronously executes a SQL query and returns the data reader to be used to process the results.

    Declaration
    public static Task<NpgsqlDataReader> ExecuteReaderAsync(this NpgsqlConnection connection, string cmdText, CommandBehavior behavior = CommandBehavior.Default, CancellationToken cancellationToken = default, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string cmdText

    The SQL command.

    CommandBehavior behavior

    Optionally specifies the command behavior.

    CancellationToken cancellationToken

    Optional cancellation token.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    Task<NpgsqlDataReader>

    The Npgsql.NpgsqlDataReader.

    Remarks
    note

    Although this method is convenient, consider explictly creating and preparing Npgsql.NpgsqlCommand for frequently executed commands for better performance.

    ExecuteScalar(NpgsqlConnection, string, NpgsqlTransaction)

    Executes a SQL query and returns the first column from the first row returned. All other rows and columns will be ignored.

    Declaration
    public static object ExecuteScalar(this NpgsqlConnection connection, string cmdText, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string cmdText

    The SQL command.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    object

    The value of the first column on the first row returned by the command.

    Remarks
    note

    Although this method is convenient, consider explictly creating and preparing Npgsql.NpgsqlCommand for frequently executed commands for better performance.

    ExecuteScalarAsync(NpgsqlConnection, string, CancellationToken, NpgsqlTransaction)

    Asynchronously executes a SQL query and returns the first column from the first row returned. All other rows and columns will be ignored.

    Declaration
    public static Task<object> ExecuteScalarAsync(this NpgsqlConnection connection, string cmdText, CancellationToken cancellationToken = default, NpgsqlTransaction transaction = null)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The database connection.

    string cmdText

    The SQL command.

    CancellationToken cancellationToken

    Optional cancellation token.

    NpgsqlTransaction transaction

    Optionally specifies the transaction.

    Returns
    Type Description
    Task<object>

    The value of the first column on the first row returned by the command.

    Remarks
    note

    Although this method is convenient, consider explictly creating and preparing Npgsql.NpgsqlCommand for frequently executed commands for better performance.

    OpenDatabase(NpgsqlConnection, string)

    Clones an existing database connection by retaining all connection settings except that the new connection will be opened to target a new database.

    Declaration
    public static NpgsqlConnection OpenDatabase(this NpgsqlConnection connection, string database)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The existing connection.

    string database

    The target database for the new connection.

    Returns
    Type Description
    NpgsqlConnection

    The new Npgsql.NpgsqlConnection.

    OpenDatabaseAsync(NpgsqlConnection, string)

    Asynchronously clones an existing database connection by retaining all connection settings except that the connection will be opened to target a new database.

    Declaration
    public static Task<NpgsqlConnection> OpenDatabaseAsync(this NpgsqlConnection connection, string database)
    Parameters
    Type Name Description
    NpgsqlConnection connection

    The existing connection.

    string database

    The target database for the new connection.

    Returns
    Type Description
    Task<NpgsqlConnection>

    The new Npgsql.NpgsqlConnection.

    In this article
    Back to top © Copyright 2005-2023 by NEONFORGE LLC