Exemple #1
0
        public OracleDataProvider(string name, OracleVersion version)
            : base(
                name,
                GetMappingSchema(name, OracleProviderAdapter.GetInstance(name).MappingSchema),
                OracleProviderAdapter.GetInstance(name))
        {
            Version = version;

            //SqlProviderFlags.IsCountSubQuerySupported        = false;
            SqlProviderFlags.IsIdentityParameterRequired       = true;
            SqlProviderFlags.IsCommonTableExpressionsSupported = true;
            SqlProviderFlags.IsSubQueryOrderBySupported        = true;
            SqlProviderFlags.IsDistinctOrderBySupported        = false;
            SqlProviderFlags.IsUpdateFromSupported             = false;
            SqlProviderFlags.DefaultMultiQueryIsolationLevel   = IsolationLevel.ReadCommitted;

            if (version >= OracleVersion.v12)
            {
                SqlProviderFlags.IsApplyJoinSupported = true;
            }

            SqlProviderFlags.MaxInListValuesCount = 1000;

            SetCharField("Char", (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharField("NChar", (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharFieldToType <char>("Char", (r, i) => DataTools.GetChar(r, i));
            SetCharFieldToType <char>("NChar", (r, i) => DataTools.GetChar(r, i));

            if (version == OracleVersion.v11)
            {
                _sqlOptimizer = new Oracle11SqlOptimizer(SqlProviderFlags);
            }
            else
            {
                _sqlOptimizer = new Oracle12SqlOptimizer(SqlProviderFlags);
            }

            SetProviderField(Adapter.OracleBFileType, Adapter.OracleBFileType, Adapter.GetOracleBFileReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleBinaryType, Adapter.OracleBinaryType, Adapter.GetOracleBinaryReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleBlobType, Adapter.OracleBlobType, Adapter.GetOracleBlobReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleClobType, Adapter.OracleClobType, Adapter.GetOracleClobReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleDateType, Adapter.OracleDateType, Adapter.GetOracleDateReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleDecimalType, Adapter.OracleDecimalType, Adapter.GetOracleDecimalReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleIntervalDSType, Adapter.OracleIntervalDSType, Adapter.GetOracleIntervalDSReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleIntervalYMType, Adapter.OracleIntervalYMType, Adapter.GetOracleIntervalYMReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleStringType, Adapter.OracleStringType, Adapter.GetOracleStringReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleTimeStampType, Adapter.OracleTimeStampType, Adapter.GetOracleTimeStampReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleTimeStampLTZType, Adapter.OracleTimeStampLTZType, Adapter.GetOracleTimeStampLTZReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleTimeStampTZType, Adapter.OracleTimeStampTZType, Adapter.GetOracleTimeStampTZReaderMethod, dataReaderType: Adapter.DataReaderType);
            SetProviderField(Adapter.OracleXmlTypeType, Adapter.OracleXmlTypeType, Adapter.GetOracleXmlTypeReaderMethod, dataReaderType: Adapter.DataReaderType);

            // native provider only
            if (Adapter.OracleRefType != null)
            {
                SetProviderField(Adapter.OracleRefType, Adapter.OracleRefType, Adapter.GetOracleRefReaderMethod !, dataReaderType: Adapter.DataReaderType);
            }

            ReaderExpressions[new ReaderInfo {
                                  ToType = typeof(DateTimeOffset), ProviderFieldType = Adapter.OracleTimeStampTZType, DataReaderType = Adapter.DataReaderType
                              }]
                = Adapter.ReadDateTimeOffsetFromOracleTimeStampTZ;

            ReaderExpressions[new ReaderInfo {
                                  ToType = typeof(decimal), ProviderFieldType = Adapter.OracleDecimalType, DataReaderType = Adapter.DataReaderType
                              }] = Adapter.ReadOracleDecimalToDecimalAdv;
            ReaderExpressions[new ReaderInfo {
                                  ToType = typeof(decimal), FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                              }] = Adapter.ReadOracleDecimalToDecimalAdv;
            ReaderExpressions[new ReaderInfo {
                                  ToType = typeof(int), FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                              }] = Adapter.ReadOracleDecimalToInt;
            ReaderExpressions[new ReaderInfo {
                                  ToType = typeof(long), FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                              }] = Adapter.ReadOracleDecimalToLong;
            ReaderExpressions[new ReaderInfo {
                                  FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                              }] = Adapter.ReadOracleDecimalToDecimal;
            ReaderExpressions[new ReaderInfo {
                                  ToType = typeof(DateTimeOffset), ProviderFieldType = Adapter.OracleTimeStampLTZType, DataReaderType = Adapter.DataReaderType
                              }] = Adapter.ReadDateTimeOffsetFromOracleTimeStampLTZ;
        }
Exemple #2
0
        protected OracleDataProvider(string name, OracleProvider provider, OracleVersion version)
            : base(name, GetMappingSchema(provider, version), OracleProviderAdapter.GetInstance(provider))
        {
            Provider = provider;
            Version  = version;

            SqlProviderFlags.IsIdentityParameterRequired       = true;
            SqlProviderFlags.IsCommonTableExpressionsSupported = true;
            SqlProviderFlags.IsSubQueryOrderBySupported        = true;
            SqlProviderFlags.IsDistinctOrderBySupported        = false;
            SqlProviderFlags.IsUpdateFromSupported             = false;
            SqlProviderFlags.DefaultMultiQueryIsolationLevel   = IsolationLevel.ReadCommitted;
            SqlProviderFlags.IsNamingQueryBlockSupported       = true;

            SqlProviderFlags.RowConstructorSupport = RowFeature.Equality | RowFeature.CompareToSelect | RowFeature.In |
                                                     RowFeature.Update | RowFeature.Overlaps;

            if (version >= OracleVersion.v12)
            {
                SqlProviderFlags.IsApplyJoinSupported = true;
            }

            SqlProviderFlags.MaxInListValuesCount = 1000;

            SetCharField("Char", (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharField("NChar", (r, i) => r.GetString(i).TrimEnd(' '));
            SetCharFieldToType <char>("Char", DataTools.GetCharExpression);
            SetCharFieldToType <char>("NChar", DataTools.GetCharExpression);

            if (version == OracleVersion.v11)
            {
                _sqlOptimizer = new Oracle11SqlOptimizer(SqlProviderFlags);
            }
            else
            {
                _sqlOptimizer = new Oracle12SqlOptimizer(SqlProviderFlags);
            }

            foreach (var(type, method) in Adapter.CustomReaders)
            {
                SetProviderField(type, type, method, dataReaderType: Adapter.DataReaderType);
            }

            if (Adapter.OracleTimeStampTZType != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(DateTimeOffset), ProviderFieldType = Adapter.OracleTimeStampTZType, DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadDateTimeOffsetFromOracleTimeStampTZ;
            }
            else
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(DateTimeOffset), ProviderFieldType = Adapter.OracleTimeStampType, DataReaderType = Adapter.DataReaderType, DataTypeName = "TIMESTAMP WITH TIME ZONE"
                                  }] = Adapter.ReadDateTimeOffsetFromOracleTimeStampTZ;
            }

            if (Adapter.ReadDateTimeOffsetFromOracleTimeStamp != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(DateTimeOffset), ProviderFieldType = Adapter.OracleTimeStampType, DataReaderType = Adapter.DataReaderType, DataTypeName = "TIMESTAMP"
                                  }] = Adapter.ReadDateTimeOffsetFromOracleTimeStamp;
            }

            if (Adapter.ReadOracleDecimalToDecimalAdv != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(decimal), ProviderFieldType = Adapter.OracleDecimalType, DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadOracleDecimalToDecimalAdv;
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(decimal), FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadOracleDecimalToDecimalAdv;
            }
            if (Adapter.ReadOracleDecimalToInt != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(int), FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadOracleDecimalToInt;
            }
            if (Adapter.ReadOracleDecimalToLong != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(long), FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadOracleDecimalToLong;
            }
            if (Adapter.ReadOracleDecimalToDecimal != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      FieldType = typeof(decimal), DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadOracleDecimalToDecimal;
            }
            if (Adapter.ReadDateTimeOffsetFromOracleTimeStampLTZ != null)
            {
                ReaderExpressions[new ReaderInfo {
                                      ToType = typeof(DateTimeOffset), ProviderFieldType = Adapter.OracleTimeStampLTZType, DataReaderType = Adapter.DataReaderType
                                  }] = Adapter.ReadDateTimeOffsetFromOracleTimeStampLTZ;
            }
        }