public override void Visit(DbScanExpression expression) { if (EF6MetadataHelpers.GetMetadataProperty <string>((MetadataItem)expression.Target, "DefiningQuery") != null) { throw new InvalidOperationException(EFProviderSettings.Instance.GetErrorMessage(-5001)); } this._commandText.Append(SqlGenerator.GetTargetTSql(expression.Target)); }
public override TypeUsage GetStoreType(TypeUsage edmType) { bool bUse32DataTypes = ODTSettings.m_bUse32DataTypes; if (EFProviderSettings.s_tracingEnabled) { EFProviderSettings.Instance.Trace(EFProviderSettings.EFTraceLevel.Entry, " (ENTRY) EFOracleProviderManifest::GetStoreType() \n"); } EntityUtils.CheckArgumentNull <TypeUsage>(edmType, nameof(edmType)); PrimitiveType edmType1 = edmType.EdmType as PrimitiveType; if (edmType1 == null) { throw new ArgumentException(EFProviderSettings.Instance.GetErrorMessage(-1703, "Oracle Data Provider for .NET", edmType.EdmType.FullName)); } ReadOnlyMetadataCollection <Facet> facets = edmType.Facets; if (EFProviderSettings.s_tracingEnabled) { EFProviderSettings.Instance.Trace(EFProviderSettings.EFTraceLevel.Entry, " (EXIT) EFOracleProviderManifest::GetStoreType() \n"); } switch (edmType1.PrimitiveTypeKind) { case PrimitiveTypeKind.Binary: bool flag1 = facets["FixedLength"].Value != null && (bool)facets["FixedLength"].Value; Facet facet1 = facets["MaxLength"]; bool flag2 = !bUse32DataTypes ? facet1.IsUnbounded || facet1.Value == null || (int)facet1.Value > 2000 : facet1.IsUnbounded || facet1.Value == null || (int)facet1.Value > this.BinaryMaxSize_12c; int maxLength1 = !flag2 ? (int)facet1.Value : int.MinValue; return(!flag1 ? (!flag2 ? TypeUsage.CreateBinaryTypeUsage(this.StoreTypeNameToStorePrimitiveType["raw"], false, maxLength1) : TypeUsage.CreateBinaryTypeUsage(this.StoreTypeNameToStorePrimitiveType["blob"], false)) : (!bUse32DataTypes ? TypeUsage.CreateBinaryTypeUsage(this.StoreTypeNameToStorePrimitiveType["raw"], true, flag2 ? 2000 : maxLength1) : TypeUsage.CreateBinaryTypeUsage(this.StoreTypeNameToStorePrimitiveType["raw"], true, flag2 ? this.BinaryMaxSize_12c : maxLength1))); case PrimitiveTypeKind.Boolean: return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], (byte)EFOracleProviderManifest.m_edmMappingMaxBOOL, (byte)0)); case PrimitiveTypeKind.Byte: return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], (byte)EFOracleProviderManifest.m_edmMappingMaxBYTE, (byte)0)); case PrimitiveTypeKind.DateTime: if (facets == null || facets["Precision"].Value == null) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["date"])); } if ((int)(byte)facets["Precision"].Value > 9) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["timestamp with local time zone"])); } return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["timestamp"])); case PrimitiveTypeKind.Decimal: byte precision; byte scale; if (EF6MetadataHelpers.TryGetPrecision(edmType, out precision) && EF6MetadataHelpers.TryGetScale(edmType, out scale)) { if ((int)precision == 250 && (int)scale == 0) { return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["interval year to month"], (byte)9, (byte)0)); } if ((int)precision == 251 && (int)scale == 0) { return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["interval day to second"], (byte)9, (byte)0)); } return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], precision, scale)); } if (EF6MetadataHelpers.TryGetPrecision(edmType, out precision)) { return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], precision, (byte)0)); } if (EF6MetadataHelpers.TryGetScale(edmType, out scale)) { return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], (byte)38, scale)); } return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["number"])); case PrimitiveTypeKind.Double: if (this._version < EFOracleVersion.Oracle10gR1) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["number"])); } return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["binary_double"])); case PrimitiveTypeKind.Guid: return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["guid raw"])); case PrimitiveTypeKind.Single: if (this._version < EFOracleVersion.Oracle10gR1) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["number"])); } return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["binary_float"])); case PrimitiveTypeKind.Int16: return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], (byte)EFOracleProviderManifest.m_edmMappingMaxINT16, (byte)0)); case PrimitiveTypeKind.Int32: return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], (byte)EFOracleProviderManifest.m_edmMappingMaxINT32, (byte)0)); case PrimitiveTypeKind.Int64: return(TypeUsage.CreateDecimalTypeUsage(this.StoreTypeNameToStorePrimitiveType["number"], (byte)EFOracleProviderManifest.m_edmMappingMaxINT64, (byte)0)); case PrimitiveTypeKind.String: bool flag3 = facets["Unicode"].Value == null || (bool)facets["Unicode"].Value; bool flag4 = facets["FixedLength"].Value != null && (bool)facets["FixedLength"].Value; Facet facet2 = facets["MaxLength"]; bool flag5 = !bUse32DataTypes ? facet2.IsUnbounded || facet2.Value == null || (int)facet2.Value > (flag3 ? 4000 : 4000) : facet2.IsUnbounded || facet2.Value == null || (int)facet2.Value > (flag3 ? this.Nvarchar2MaxSize_12c : this.Varchar2MaxSize_12c); int maxLength2 = !flag5 ? (int)facet2.Value : int.MinValue; return(!flag3 ? (!flag4 ? (!flag5 ? TypeUsage.CreateStringTypeUsage(this.StoreTypeNameToStorePrimitiveType["varchar2"], false, false, maxLength2) : TypeUsage.CreateStringTypeUsage(this.StoreTypeNameToStorePrimitiveType["clob"], false, false)) : TypeUsage.CreateStringTypeUsage(this.StoreTypeNameToStorePrimitiveType["char"], false, true, flag5 ? 2000 : maxLength2)) : (!flag4 ? (!flag5 ? TypeUsage.CreateStringTypeUsage(this.StoreTypeNameToStorePrimitiveType["nvarchar2"], true, false, maxLength2) : TypeUsage.CreateStringTypeUsage(this.StoreTypeNameToStorePrimitiveType["nclob"], true, false)) : TypeUsage.CreateStringTypeUsage(this.StoreTypeNameToStorePrimitiveType["nchar"], true, true, flag5 ? 2000 : maxLength2))); case PrimitiveTypeKind.DateTimeOffset: return(TypeUsage.CreateDefaultTypeUsage((EdmType)this.StoreTypeNameToStorePrimitiveType["timestamp with time zone"])); default: throw new NotSupportedException(EFProviderSettings.Instance.GetErrorMessage(-1703, "Oracle Data Provider for .NET", edmType1.PrimitiveTypeKind.ToString())); } }
public override TypeUsage GetEdmType(TypeUsage storeType) { if (EFProviderSettings.s_tracingEnabled) { EFProviderSettings.Instance.Trace(EFProviderSettings.EFTraceLevel.Entry, " (ENTRY) EFOracleProviderManifest::GetEdmType()\n"); } EntityUtils.CheckArgumentNull <TypeUsage>(storeType, nameof(storeType)); string lowerInvariant = storeType.EdmType.Name.ToLowerInvariant(); if (!this.StoreTypeNameToEdmPrimitiveType.ContainsKey(lowerInvariant)) { throw new ArgumentException(EFProviderSettings.Instance.GetErrorMessage(-1703, "Oracle Data Provider for .NET", lowerInvariant)); } PrimitiveType primitiveType = this.StoreTypeNameToEdmPrimitiveType[lowerInvariant]; int maxLength = 0; bool isUnicode = true; if (EFProviderSettings.s_tracingEnabled) { EFProviderSettings.Instance.Trace(EFProviderSettings.EFTraceLevel.Entry, " (EXIT) EFOracleProviderManifest::GetEdmType()\n"); } PrimitiveTypeKind primitiveTypeKind1; bool flag; bool isFixedLength; switch (lowerInvariant) { case "int": case "smallint": case "binary_integer": case "pl/sql boolean": return(TypeUsage.CreateDefaultTypeUsage((EdmType)primitiveType)); case "mlslabel": return(TypeUsage.CreateBinaryTypeUsage(primitiveType, true, 12345)); case "varchar2": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isUnicode = false; isFixedLength = false; break; case "char": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isUnicode = false; isFixedLength = true; break; case "nvarchar2": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isUnicode = true; isFixedLength = false; break; case "nchar": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isUnicode = true; isFixedLength = true; break; case "clob": case "long": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = true; isUnicode = false; isFixedLength = false; break; case "xmltype": case "nclob": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = true; isUnicode = true; isFixedLength = false; break; case "blob": case "bfile": primitiveTypeKind1 = PrimitiveTypeKind.Binary; flag = true; isFixedLength = false; break; case "raw": primitiveTypeKind1 = PrimitiveTypeKind.Binary; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isFixedLength = false; if (maxLength == 16) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Guid))); } break; case "long raw": primitiveTypeKind1 = PrimitiveTypeKind.Binary; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isFixedLength = false; break; case "guid raw": return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Guid))); case "guid": case "binary_float": case "binary_double": return(TypeUsage.CreateDefaultTypeUsage((EdmType)primitiveType)); case "rowid": case "urowid": primitiveTypeKind1 = PrimitiveTypeKind.String; flag = !EF6MetadataHelpers.TryGetMaxLength(storeType, out maxLength); isUnicode = false; isFixedLength = false; break; case "float": byte precision1; byte scale1; if (!EF6MetadataHelpers.TryGetPrecision(storeType, out precision1) || !EF6MetadataHelpers.TryGetScale(storeType, out scale1)) { return(TypeUsage.CreateDecimalTypeUsage(primitiveType)); } byte precision2 = byte.Parse(((int)((double)Convert.ToInt32(precision1) * 0.30103 + 1.0)).ToString()); return(TypeUsage.CreateDecimalTypeUsage(primitiveType, precision2, scale1)); case "odp_internal_use_type": return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Boolean))); case "number": byte precision3; byte scale2; if (!EF6MetadataHelpers.TryGetPrecision(storeType, out precision3) || !EF6MetadataHelpers.TryGetScale(storeType, out scale2)) { return(TypeUsage.CreateDecimalTypeUsage(primitiveType)); } if (!ConfigBaseClass.s_bLegacyEdmMappingPresent && (int)scale2 == 0) { if ((int)precision3 < 0 || (int)precision3 > 38) { precision3 = (byte)0; } DbType key = ConfigBaseClass.s_edmPrecisonMapping[(int)precision3]; if (EFOracleProviderManifest.s_DbTypeToPrimitiveTypeKind.ContainsKey(key)) { PrimitiveTypeKind primitiveTypeKind2; EFOracleProviderManifest.s_DbTypeToPrimitiveTypeKind.TryGetValue(key, out primitiveTypeKind2); if (primitiveTypeKind2 == PrimitiveTypeKind.Boolean || primitiveTypeKind2 == PrimitiveTypeKind.Byte || (primitiveTypeKind2 == PrimitiveTypeKind.Int16 || primitiveTypeKind2 == PrimitiveTypeKind.Int32) || primitiveTypeKind2 == PrimitiveTypeKind.Int64) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(primitiveTypeKind2))); } if (primitiveTypeKind2 == PrimitiveTypeKind.Decimal) { return(TypeUsage.CreateDecimalTypeUsage(primitiveType, precision3, scale2)); } } } if ((int)precision3 == 1 && (int)scale2 == 0) { if (EFOracleProviderManifest.m_bMapNumberToBoolean && (int)precision3 <= (int)(byte)EFOracleProviderManifest.m_edmMappingMaxBOOL) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Boolean))); } if (EFOracleProviderManifest.m_bMapNumberToByte && (int)precision3 <= (int)(byte)EFOracleProviderManifest.m_edmMappingMaxBYTE) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Byte))); } return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int16))); } if (EFOracleProviderManifest.m_bMapNumberToByte && (int)scale2 == 0 && (int)precision3 <= (int)(byte)EFOracleProviderManifest.m_edmMappingMaxBYTE) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Byte))); } if ((int)scale2 == 0 && (int)precision3 <= (int)(byte)EFOracleProviderManifest.m_edmMappingMaxINT16) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int16))); } if ((int)scale2 == 0 && (int)precision3 <= (int)(byte)EFOracleProviderManifest.m_edmMappingMaxINT32) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int32))); } if ((int)scale2 == 0 && (int)precision3 <= (int)(byte)EFOracleProviderManifest.m_edmMappingMaxINT64) { return(TypeUsage.CreateDefaultTypeUsage((EdmType)PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.Int64))); } return(TypeUsage.CreateDecimalTypeUsage(primitiveType, precision3, scale2)); case "date": return(TypeUsage.CreateDateTimeTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.DateTime), new byte?())); case "timestamp": byte byteValue; if (EF6MetadataHelpers.TryGetByteFacetValue(storeType, "Precision", out byteValue)) { return(TypeUsage.CreateDateTimeTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.DateTime), new byte?(byteValue))); } return(TypeUsage.CreateDateTimeTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.DateTime), new byte?((byte)9))); case "timestamp with time zone": return(TypeUsage.CreateDateTimeOffsetTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.DateTimeOffset), new byte?((byte)9))); case "timestamp with local time zone": return(TypeUsage.CreateDateTimeTypeUsage(PrimitiveType.GetEdmPrimitiveType(PrimitiveTypeKind.DateTime), new byte?(byte.MaxValue))); case "interval year to month": return(TypeUsage.CreateDecimalTypeUsage(primitiveType, (byte)250, (byte)0)); case "interval day to second": return(TypeUsage.CreateDecimalTypeUsage(primitiveType, (byte)251, (byte)0)); default: throw new NotSupportedException(EFProviderSettings.Instance.GetErrorMessage(-1703, "Oracle Data Provider for .NET", lowerInvariant)); } switch (primitiveTypeKind1) { case PrimitiveTypeKind.Binary: if (!flag) { return(TypeUsage.CreateBinaryTypeUsage(primitiveType, isFixedLength, maxLength)); } return(TypeUsage.CreateBinaryTypeUsage(primitiveType, isFixedLength)); case PrimitiveTypeKind.String: if (!flag) { return(TypeUsage.CreateStringTypeUsage(primitiveType, isUnicode, isFixedLength, maxLength)); } return(TypeUsage.CreateStringTypeUsage(primitiveType, isUnicode, isFixedLength)); default: throw new NotSupportedException(EFProviderSettings.Instance.GetErrorMessage(-1703, "Oracle Data Provider for .NET", lowerInvariant)); } }