Show / Hide Table of Contents

    InformixExtensions.UseInformix<TAdoDbContext>(this IDataContextOptions<TAdoDbContext> contextOptions, string connectionString, Action<InformixDataContextOptions<TAdoDbContext>> options) Method

    .NET Standard 2.x

    Configures the context to connect to an Informix database.

    Namespace: SnapObjects.Data.Informix

    Assembly: SnapObjects.Data.Informix.dll

    Syntax

    public static IDataContextOptions<TAdoDbContext> UseInformix<TAdoDbContext>(this IDataContextOptions<TAdoDbContext> contextOptions, string connectionString, Action<InformixDataContextOptions<TAdoDbContext>> options) where TAdoDbContext : InformixDataContext
    

    Type Parameters

    TAdoDbContext

    The type of context to be configured.

    Parameters

    contextOptions IDataContextOptions<TAdoDbContext>

    The options being used to configure the context.

    connectionString System.String

    A string containing connection information about how to connect to the data source.

    InformixOptionsAction Action<InformixDataContextOptions<TAdoDbContext>>

    (Optional) An action to allow additional Informix-specific configuration.

    Returns

    SnapObjects.Data.IDataContextOptions<TAdoDbContext>

    An IDataContextOptions<TAdoDbContext> object which contains options of the DataContext object.

    Examples

    The following code demonstrates how to use the UseInformix method in the ConfigureServices method of the Startup class.

    using Microsoft.Extensions.DependencyInjection;
    using SnapObjects.Data;
    using SnapObjects.Data.Informix;
    using Microsoft.Extensions.Configuration;
    
    namespace Appeon.ApiDoc.InformixExtensionsExamples
    {
        public class StartUp
        {
            public IConfiguration Configuration { get; }
    
            public StartUp(IConfiguration configuration)
            {
                Configuration = configuration;
            }
    
            string CONNECTION_STRING = "Database=***;User ID=***;Password=***;Server=***";
    
            // This method gets called by the runtime. Use this method to add services to the container.
            public void ConfigureServices(IServiceCollection services)
            {
                // UseInformix with connection string.
                services.AddDataContext<InformixContext>(m => m.UseInformix(CONNECTION_STRING));
    
                // UseInformix with connection string and other options.
                services.AddDataContext<InformixContext>(m => m.UseInformix(CONNECTION_STRING, n => n.TrimSpaces = true));
    
                // UseInformix with the IConfiguration object and the key specified in the connection strings.
                services.AddDataContext<InformixContext>(m => m.UseInformix(this.Configuration, "MyConnectionString"));
    
            }
        }
    }
    

    Applies to

    .NET Standard

    2.x

    Back to top Generated by Appeon