Esempio n. 1
0
 public static DB2iSeriesDataProvider GetDataProvider(
     DB2iSeriesVersion version,
     DB2iSeriesProviderType providerType,
     DB2iSeriesMappingOptions mappingOptions)
 {
     return(GetDataProvider(DB2iSeriesProviderName.GetProviderName(version, providerType, mappingOptions)));
 }
 /// <summary>
 /// Build a DB2 iSeries data provider. The name will be infered from options and will be one of the constants in the DB2iSeriesProviderName class
 /// </summary>
 /// <param name="providerType">Undelying Ado.Net provider type</param>
 /// <param name="version">iSeries version</param>
 /// <param name="mappingOptions">Mapping specific options</param>
 public DB2iSeriesDataProvider(
     DB2iSeriesProviderType providerType     = DB2iSeriesProviderOptions.Defaults.ProviderType,
     DB2iSeriesVersion version               = DB2iSeriesProviderOptions.Defaults.Version,
     DB2iSeriesMappingOptions mappingOptions = null)
     : this(DB2iSeriesProviderName.GetProviderName(version, providerType, mappingOptions ?? DB2iSeriesMappingOptions.Default))
 {
 }
 /// <summary>
 /// Build a DB2 iSeries data provider.
 /// </summary>
 /// <param name="name">Configuration name</param>
 /// <param name="providerType">Undelying Ado.Net provider type</param>
 /// <param name="version">iSeries version</param>
 /// <param name="mappingOptions">Mapping specific options</param>
 public DB2iSeriesDataProvider(
     string name,
     DB2iSeriesProviderType providerType     = DB2iSeriesProviderOptions.Defaults.ProviderType,
     DB2iSeriesVersion version               = DB2iSeriesProviderOptions.Defaults.Version,
     DB2iSeriesMappingOptions mappingOptions = null)
     : this(new DB2iSeriesProviderOptions(name, providerType, version)
 {
     MapGuidAsString = mappingOptions?.MapGuidAsString ?? DB2iSeriesProviderOptions.Defaults.MapGuidAsString
 })
 {
 }
        /// <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();
            }
        }
        public static string GetProviderName(
            DB2iSeriesVersion version,
            DB2iSeriesProviderType providerType,
            DB2iSeriesMappingOptions mappingOptions)
        {
            var mapGuidAsString = mappingOptions.MapGuidAsString;

            return(providerType switch
            {
#if NETFRAMEWORK
                DB2iSeriesProviderType.AccessClient => version switch
                {
                    DB2iSeriesVersion.V7_1 => mapGuidAsString ? DB2_AccessClient_71_GAS : DB2_AccessClient_71,
                    DB2iSeriesVersion.V7_2 => mapGuidAsString ? DB2_AccessClient_72_GAS : DB2_AccessClient_72,
                    _ => mapGuidAsString ? DB2_AccessClient_73_GAS : DB2_AccessClient_73,
                },