using System.Collections.Generic; using System.Linq; namespace SqlSugar { public class OracleDbBind : DbBindProvider { public override string GetPropertyTypeName(string dbTypeName) { dbTypeName = dbTypeName.ToLower(); var propertyTypes = MappingTypes.Where(it => it.Value.ToString().ToLower() == dbTypeName || it.Key.ToLower() == dbTypeName); if (dbTypeName == "int32") { return "int"; } else if (dbTypeName == "int64") { return "long"; } else if (dbTypeName == "int16") { return "short"; } else if (propertyTypes == null) { return "other"; } else if (dbTypeName == "xml" || dbTypeName == "string") { return "string"; } if (dbTypeName == "byte[]") { return "byte[]"; } else if (propertyTypes == null || propertyTypes.Count() == 0) { Check.ThrowNotSupportedException(string.Format(" \"{0}\" Type NotSupported, DbBindProvider.GetPropertyTypeName error.", dbTypeName)); return null; } else if (propertyTypes.First().Value == CSharpDataType.byteArray) { return "byte[]"; } else { return propertyTypes.First().Value.ToString(); } } public override List> MappingTypes { get { var extService = this.Context.CurrentConnectionConfig.ConfigureExternalServices; if (extService != null && extService.AppendDataReaderTypeMappings.HasValue()) { return extService.AppendDataReaderTypeMappings.Union(MappingTypesConst).ToList(); } else { return MappingTypesConst; } } } public static List> MappingTypesConst = new List> { new KeyValuePair("int",CSharpDataType.@int), new KeyValuePair("integer",CSharpDataType.@int), new KeyValuePair("interval year to month",CSharpDataType.@int), new KeyValuePair("interval day to second",CSharpDataType.@int), new KeyValuePair("number",CSharpDataType.@int), new KeyValuePair("number",CSharpDataType.@float), new KeyValuePair("number",CSharpDataType.@short), new KeyValuePair("number",CSharpDataType.@byte), new KeyValuePair("number",CSharpDataType.@double), new KeyValuePair("number",CSharpDataType.@long), new KeyValuePair("number",CSharpDataType.@bool), new KeyValuePair("number",CSharpDataType.@decimal), new KeyValuePair("number",CSharpDataType.Single), new KeyValuePair("decimal",CSharpDataType.@decimal), new KeyValuePair("decimal",CSharpDataType.Single), new KeyValuePair("varchar",CSharpDataType.@string), new KeyValuePair("varchar2",CSharpDataType.@string), new KeyValuePair("nvarchar2",CSharpDataType.@string), new KeyValuePair("char",CSharpDataType.@string), new KeyValuePair("nchar",CSharpDataType.@string), new KeyValuePair("clob",CSharpDataType.@string), new KeyValuePair("long",CSharpDataType.@string), new KeyValuePair("nclob",CSharpDataType.@string), new KeyValuePair("rowid",CSharpDataType.@string), new KeyValuePair("date",CSharpDataType.DateTime), new KeyValuePair("timestamp",CSharpDataType.DateTime), new KeyValuePair("timestamp with local time zone",CSharpDataType.DateTime), new KeyValuePair("timestamp with time zone",CSharpDataType.DateTime), new KeyValuePair("timestamp with time zone",CSharpDataType.DateTime), new KeyValuePair("float",CSharpDataType.@decimal), new KeyValuePair("blob",CSharpDataType.byteArray), new KeyValuePair("long raw",CSharpDataType.byteArray), new KeyValuePair("raw",CSharpDataType.byteArray), new KeyValuePair("bfile",CSharpDataType.byteArray), new KeyValuePair("varbinary",CSharpDataType.byteArray) }; public override List StringThrow { get { return new List { "int32", "datetime", "decimal", "double", "byte" }; } } } }