コード例 #1
0
        /// <summary>
        /// Build a DB2 iSeries data provider.
        /// </summary>
        /// <param name="providerOptions">The provider's construction options, see <see cref="DB2iSeriesProviderOptions"/></param>
        public DB2iSeriesDataProvider(DB2iSeriesProviderOptions providerOptions)
            : base(
                providerOptions.ProviderName,
                GetMappingSchema(
                    providerOptions.ProviderName,
                    providerOptions.ProviderType,
                    providerOptions.MapGuidAsString),
                DB2iSeriesProviderAdapter.GetInstance(providerOptions.ProviderType))
        {
            this.db2iSeriesSqlProviderFlags = new DB2iSeriesSqlProviderFlags(providerOptions);
            this.mappingOptions             = new DB2iSeriesMappingOptions(providerOptions);
            this.ProviderType = providerOptions.ProviderType;

            DB2iSeriesLoadExpressions.SetupExpressions(providerOptions.ProviderName, mappingOptions.MapGuidAsString);

            SqlProviderFlags.AcceptsTakeAsParameter            = false;
            SqlProviderFlags.AcceptsTakeAsParameterIfSkip      = true;
            SqlProviderFlags.IsDistinctOrderBySupported        = false;
            SqlProviderFlags.CanCombineParameters              = false;
            SqlProviderFlags.IsCommonTableExpressionsSupported = true;
            SqlProviderFlags.IsUpdateFromSupported             = false;

            db2iSeriesSqlProviderFlags.SetCustomFlags(SqlProviderFlags);
            mappingOptions.SetCustomFlags(SqlProviderFlags);

            SetCharField(Constants.DbTypes.Char, (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharField(Constants.DbTypes.NChar, (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharField(Constants.DbTypes.Graphic, (r, i) => r.GetString(i).TrimEnd(' '));

            sqlOptimizer   = new DB2iSeriesSqlOptimizer(SqlProviderFlags, db2iSeriesSqlProviderFlags);
            schemaProvider = new DB2iSeriesSchemaProvider(this);
            bulkCopy       = new DB2iSeriesBulkCopy(this);

            if (ProviderType.IsOdbc())
            {
                SetupOdbc();
            }
            else if (ProviderType.IsOleDb())
            {
                SetupOleDb();
            }
#if NETFRAMEWORK
            else if (ProviderType.IsAccessClient())
            {
                SetupAccessClient();
            }
#endif
            else if (ProviderType.IsDB2())
            {
                SetupDB2Connect();
            }
        }