DbGateBuilderExtensions Methods
ClassMethods5 members
Provides extension methods for DbGate resources to an
Hosting.IDistributedApplicationBuilder. AddDbGate(IDistributedApplicationBuilder, string, int?)Section titled AddDbGate(IDistributedApplicationBuilder, string, int?)extensionIResourceBuilder<DbGateContainerResource> Adds a DbGate container resource to the application.
public static class DbGateBuilderExtensions{ public static IResourceBuilder<DbGateContainerResource> AddDbGate( this IDistributedApplicationBuilder builder, string name = "dbgate", int? port = null) { // ... }}Parameters
builderIDistributedApplicationBuilderThe resource builder.namestringoptionalThe name of the resource. This name will be used as the connection string name when referenced in a dependency. Optional; defaults to dbgate.portint?optionalThe host port to bind the underlying container to.Returns
IResourceBuilder<DbGateContainerResource>A reference to the ApplicationModel.IResourceBuilder`1.Remarks
Multiple
DbGateBuilderExtensions.AddDbGate calls will return the same resource builder instance. Sanitizes a resource name to be used as a connection ID in DbGate environment variables.
public static class DbGateBuilderExtensions{ public static string SanitizeConnectionId( string resourceName) { // ... }}Parameters
resourceNamestringThe resource name to sanitize.Returns
stringA sanitized connection ID safe for use in environment variable names.Remarks
This method performs basic sanitization by replacing hyphens with underscores, as hyphens are not valid in Linux environment variable names.
Note: Linux environment variable names have additional constraints (must contain only letters, numbers, and underscores, and cannot start with a number). This method does not validate or enforce these additional constraints. Resource names should follow standard naming conventions to ensure compatibility.
WithDataBindMount(IResourceBuilder<DbGateContainerResource>, string, bool)Section titled WithDataBindMount(IResourceBuilder<DbGateContainerResource>, string, bool)extensionIResourceBuilder<DbGateContainerResource> Adds a bind mount for the data folder to a DbGate container resource.
public static class DbGateBuilderExtensions{ public static IResourceBuilder<DbGateContainerResource> WithDataBindMount( this IResourceBuilder<DbGateContainerResource> builder, string source, bool isReadOnly = false) { // ... }}Parameters
builderIResourceBuilder<DbGateContainerResource>The resource builder.sourcestringThe source directory on the host to mount into the container.isReadOnlybooloptionalA flag that indicates if this is a read-only mount.Returns
IResourceBuilder<DbGateContainerResource>The ApplicationModel.IResourceBuilder`1.WithDataVolume(IResourceBuilder<DbGateContainerResource>, string?, bool)Section titled WithDataVolume(IResourceBuilder<DbGateContainerResource>, string?, bool)extensionIResourceBuilder<DbGateContainerResource> Adds a named volume for the data folder to a DbGate container resource.
public static class DbGateBuilderExtensions{ public static IResourceBuilder<DbGateContainerResource> WithDataVolume( this IResourceBuilder<DbGateContainerResource> builder, string? name = null, bool isReadOnly = false) { // ... }}Parameters
builderIResourceBuilder<DbGateContainerResource>The resource builder.namestring?optionalThe name of the volume. Defaults to an auto-generated name based on the application and resource names.isReadOnlybooloptionalA flag that indicates if this is a read-only volume.Returns
IResourceBuilder<DbGateContainerResource>The ApplicationModel.IResourceBuilder`1.WithHostPort(IResourceBuilder<DbGateContainerResource>, int?)Section titled WithHostPort(IResourceBuilder<DbGateContainerResource>, int?)extensionIResourceBuilder<DbGateContainerResource> Configures the host port that the DbGate resource is exposed on instead of using randomly assigned port.
public static class DbGateBuilderExtensions{ public static IResourceBuilder<DbGateContainerResource> WithHostPort( this IResourceBuilder<DbGateContainerResource> builder, int? port) { // ... }}Parameters
builderIResourceBuilder<DbGateContainerResource>The resource builder for DbGate.portint?The port to bind on the host. If null is used random port will be assigned.Returns
IResourceBuilder<DbGateContainerResource>The resource builder for DbGate.