public static DomainOptions UseJson(this DomainOptions options, JsonSerializerOptions serializerOptions)
        {
            serializerOptions ??= new JsonSerializerOptions();

            options.Use(new JsonBindingContractResolver(serializerOptions));
            options.Use(new JsonContractResolver(serializerOptions));

            return(options);
        }
Exemple #2
0
        public static DomainOptions UseNewtonsoftJson(this DomainOptions options, JsonSerializerSettings settings)
        {
            settings ??= JsonConvert.DefaultSettings?.Invoke() ?? new JsonSerializerSettings();

            options.Use(new NewtonsoftJsonBindingContractResolver(settings));
            options.Use(new NewtonsoftJsonContractResolver(settings));

            return(options);
        }
        public static DomainOptions UseEntityFrameworkCore(this DomainOptions options, DbContext dbContext)
        {
            EntityFrameworkCoreContractResolver resolver = new EntityFrameworkCoreContractResolver(dbContext);

            options.Use((IRelationContractResolver)resolver);
            options.Use((ITableContractResolver)resolver);

            return(options);
        }
        /// <summary>
        /// Configures the current domain to connect to a SQLite database with a specified connection string.
        /// </summary>
        /// <param name="options">A <see cref="DomainOptions"/> instance from the <see cref="IDomain.Configure(DomainOptions)"/> method.</param>
        /// <param name="connectionString">Connection string specifying the details of the connection.</param>
        public static DomainOptions UseSqlite(this DomainOptions options, string connectionString)
        {
            options.ConnectionFactory = () => new SqliteConnection(connectionString);
            options.Use(new SqliteContractResolver());

            return(options);
        }
Exemple #5
0
        /// <summary>
        /// Configures the current domain to connect to a MySQL database with a specified connection string.
        /// </summary>
        /// <param name="options">A <see cref="DomainOptions"/> instance from the <see cref="IDomain.Configure(DomainOptions)"/> method.</param>
        /// <param name="connectionString">Connection string specifying the details of the connection.</param>
        public static DomainOptions UseMySql(this DomainOptions options, string connectionString)
        {
            options.ConnectionFactory = () => new MySqlConnection(connectionString);
            options.Use(new MySqlContractResolver());
            options.Dialect = new MySqlDialect();

            return(options);
        }
Exemple #6
0
        /// <summary>
        /// Configures the current domain to connect to a PostgreSQL database with a specified connection string.
        /// </summary>
        /// <param name="options">A <see cref="DomainOptions"/> instance from the <see cref="IDomain.Configure(DomainOptions)"/> method.</param>
        /// <param name="connectionString">Connection string specifying the details of the connection.</param>
        public static DomainOptions UsePostgres(this DomainOptions options, string connectionString)
        {
            options.ConnectionFactory = () => new NpgsqlConnection(connectionString);
            options.Dialect           = new PostgresDialect();
            options.Use(new PostgresContractResolver());

            return(options);
        }
        /// <summary>
        /// Configures the current domain to connect to a Microsoft SQL Server database with a specified connection string.
        /// </summary>
        /// <param name="options">A <see cref="DomainOptions"/> instance from the <see cref="IDomain.Configure(DomainOptions)"/> method.</param>
        /// <param name="connectionString">Connection string specifying the details of the connection.</param>
        public static DomainOptions UseSqlServer(this DomainOptions options, string connectionString)
        {
            options.ConnectionFactory = () => new SqlConnection(connectionString);
            options.Use(new SqlServerContractResolver());
            options.Sql ??= new SqlOptions();
            options.Sql.MaxParameters = 2098;

            return(options);
        }
        /// <summary>
        /// Configures the current domain to connect to a Oracle database with a specified connection string.
        /// </summary>
        /// <param name="options">A <see cref="DomainOptions"/> instance from the <see cref="IDomain.Configure(DomainOptions)"/> method.</param>
        /// <param name="connectionString">Connection string specifying the details of the connection.</param>
        public static DomainOptions UseOracle(this DomainOptions options, string connectionString)
        {
            options.ConnectionFactory = () => new OracleConnection(connectionString);
            options.Use(new OracleContractResolver());
            options.Sql.Filters.Add(new OracleLongFilter());
            options.Dialect = new OracleDialect();

            return(options);
        }