SQL type 'datetimeoffset' is not registered
System.NotSupportedException: [DataTypeManager.GetFieldType]: SQL type 'datetimeoffset' is not registered, register the type with method RegisterDataTypes(...)
at CMS.DataEngine.DataTypeManager.GetFieldType(String sqlType, Int32 size, Boolean throwException)
at CMS.DataEngine.FieldBase`1.LoadFromTableData(DataRow row, Boolean isPrimary, Boolean isSystem)
at CMS.FormEngine.FormFieldInfo.LoadFromTableData(DataRow row, Boolean isPrimary, Boolean isSystem)
at CMS.DataEngine.DataDefinition.LoadFromDataStructure(String tableName, TableManager manager, Boolean isSystem)
at CMS.DataEngine.TableManager.GetDatabaseFields(String tableName)
at CMS.DataEngine.TableManager.GetOldFields(String tableName, String definition, Boolean loadOldDefinition)
at CMS.DataEngine.TableManager.UpdateTableByDefinition(UpdateTableParameters parameters)
at CMS.DataEngine.DataClassInfoProvider.EnsureDatabaseStructure(DataClassInfo classInfo, Boolean updateSystemFields)
at CMS.DataEngine.DataClassInfoProvider.SetDataClassInfoInternal(DataClassInfo infoObj)
at CMS.DataEngine.DataClassInfoProviderBase`1.SetDataClassInfo(DataClassInfo infoObj)
at CMS.DataEngine.DataClassInfo.SetObject()
at CMS.DataEngine.BaseInfo.Update()
// CMS.DataEngine.DataTypeManager /// <summary> /// Returns form field data type from database column data type. /// Some sql types map to multiple field types that differ by size, e.g. nvarchar has more field data types that differ by size. /// Specify size to get more accurate result. By default max size for given sql type is used. /// </summary> /// <param name="sqlType">Database column data type</param> /// <param name="size">Specify the size of sql type to get accurate result</param> /// <param name="throwException">Indicates if exception should be thrown for unsupported SQL data type</param> // Token: 0x06000903 RID: 2307 RVA: 0x0001BC38 File Offset: 0x0001AC38 public static string GetFieldType(string sqlType, int size = -1, bool throwException = false) { DataType dataType = DataTypeManager.GetDataType(TypeEnum.SQL, sqlType); if (dataType == null) { if (throwException) { throw new NotSupportedException("[DataTypeManager.GetFieldType]: SQL type '" + sqlType + "' is not registered, register the type with method RegisterDataTypes(...)"); } return ""; } else { if (dataType.FieldType == "text" && size == -1) { return "longtext"; } return dataType.FieldType; } }
// CMS.DataEngine.DataTypeManager /// <summary> /// Gets the data type settings by its SQL type /// </summary> /// <param name="typeEnum"></param> /// <param name="typeValue">SQL type</param> // Token: 0x06000909 RID: 2313 RVA: 0x0001BDDC File Offset: 0x0001ADDC public static DataType GetDataType(TypeEnum typeEnum, string typeValue) { DataType dataType = null; switch (typeEnum) { case TypeEnum.SQL: dataType = DataTypeManager.DataTypesBySqlType[typeValue]; if (dataType == null) { int num = typeValue.IndexOf("("); if (num > 0) { typeValue = typeValue.Substring(0, num); } dataType = DataTypeManager.DataTypesBySqlType[typeValue]; } break; case TypeEnum.Field: dataType = DataTypeManager.DataTypesByFieldType[typeValue]; break; case TypeEnum.Schema: dataType = DataTypeManager.DataTypesBySchemaType[typeValue]; break; } return dataType; }
// CMS.DataEngine.DataTypeManager /// <summary> /// Registers the given data type to the system /// </summary> // Token: 0x060008FB RID: 2299 RVA: 0x0001B1A5 File Offset: 0x0001A1A5 public static void RegisterDataTypes(params DataType[] types) { DataTypeManager.EnsureSystemTypes(); DataTypeManager.RegisterDataTypesInternal(false, types); }
// CMS.DataEngine.DataTypeManager // Token: 0x0600157F RID: 5503 RVA: 0x0003A920 File Offset: 0x00038B20 private static void EnsureSystemTypes() { if (!DataTypeManager.defaultTypesRegistered) { lock (DataTypeManager.lockObject) { if (!DataTypeManager.defaultTypesRegistered) { DataTypeManager.RegisterSystemTypes(); DataTypeManager.defaultTypesRegistered = true; } } } }
// CMS.DataEngine.DataTypeManager // Token: 0x06001580 RID: 5504 RVA: 0x0003A974 File Offset: 0x00038B74 private static void RegisterSystemTypes() { bool defaultTypes = true; DataType[] array = new DataType[14]; array[0] = new DataType<bool>("bit", "boolean", "xs:boolean", new Func<object, bool, CultureInfo, bool>(ValidationHelper.GetBoolean)) { TypeAlias = "bool", SqlValueFormat = "{0}", AllowEmpty = false, TypeGroup = "Boolean" }; array[1] = new DataType<int>("int", "integer", "xs:int", new Func<object, int, CultureInfo, int>(ValidationHelper.GetInteger)) { TypeAlias = "int", SqlValueFormat = "{0}", MaxValueLength = 11, TypeGroup = "Integer" }; array[2] = new DataType<long>("bigint", "longinteger", "xs:long", new Func<object, long, CultureInfo, long>(ValidationHelper.GetLong)) { TypeAlias = "long", SqlValueFormat = "{0}", MaxValueLength = 20, TypeGroup = "Integer" }; DataType[] array2 = array; int num = 3; DataType<double> dataType = new DataType<double>("float", "double", "xs:double", new Func<object, double, CultureInfo, double>(ValidationHelper.GetDouble)); dataType.TypeAlias = "double"; dataType.SqlValueFormat = "{0}"; dataType.TypeGroup = "Decimal"; dataType.GetFormatProvider = ((CultureInfo culture) => culture.NumberFormat); array2[num] = dataType; DataType[] array3 = array; int num2 = 4; DataType<DateTime> dataType2 = new DataType<DateTime>("datetime2", "datetime", "xs:dateTime", new Func<object, DateTime, CultureInfo, DateTime>(ValidationHelper.GetDateTime)); dataType2.DbType = SqlDbType.DateTime2; dataType2.DefaultValueCode = "DateTimeHelper.ZERO_TIME"; dataType2.CodeValueFormat = "DateTime.Parse(\"{0}\")"; dataType2.VariablePrecision = true; dataType2.DefaultPrecision = 7; dataType2.MaxPrecision = 7; dataType2.SpecialDefaultValues = new List<string> { "##TODAY##", "##NOW##" }; dataType2.TypeGroup = "DateTime"; dataType2.GetFormatProvider = ((CultureInfo culture) => culture.DateTimeFormat); array3[num2] = dataType2; array[5] = new DataType<string>("nvarchar(max)", "longtext", "xs:string", new Func<object, string, CultureInfo, string>(ValidationHelper.GetString)) { TypeAlias = "string", SqlValueFormat = "N'{0}'", CodeValueFormat = "\"{0}\"", DefaultValueCode = "String.Empty", DefaultValue = "", SupportsTranslation = true, TypeGroup = "LongText" }; array[6] = new DataType<byte[]>("varbinary(max)", "binary", "xs:base64binary", new Func<object, byte[], CultureInfo, byte[]>(ValidationHelper.GetBinary)) { TypeAlias = "byte[]", SupportsTranslation = true, DbType = SqlDbType.VarBinary, TypeGroup = "Binary", HasConfigurableDefaultValue = false, AllowedObjectTypes = new string[] { "cms.systemtable", "cms.class" } }; array[7] = new DataType<Guid>("uniqueidentifier", "guid", "xs:string", new Func<object, Guid, CultureInfo, Guid>(ValidationHelper.GetGuid)) { DefaultValueCode = "Guid.Empty", TypeGroup = "Guid" }; DataType[] array4 = array; int num3 = 8; DataType<decimal> dataType3 = new DataType<decimal>("decimal", "decimal", "xs:decimal", new Func<object, decimal, CultureInfo, decimal>(ValidationHelper.GetDecimal)); dataType3.TypeAlias = "decimal"; dataType3.VariableSize = true; dataType3.DefaultSize = 19; dataType3.MaxSize = 38; dataType3.VariablePrecision = true; dataType3.DefaultPrecision = 4; dataType3.MaxPrecision = 38; dataType3.TypeGroup = "Decimal"; dataType3.GetFormatProvider = ((CultureInfo culture) => culture.NumberFormat); array4[num3] = dataType3; DataType[] array5 = array; int num4 = 9; DataType<TimeSpan> dataType4 = new DataType<TimeSpan>("time", "timespan", "xs:duration", new Func<object, TimeSpan, CultureInfo, TimeSpan>(ValidationHelper.GetTimeSpan)); dataType4.DbType = SqlDbType.Time; dataType4.DefaultValueCode = "TimeSpan.MinValue"; dataType4.VariablePrecision = true; dataType4.DefaultPrecision = 7; dataType4.MaxPrecision = 7; dataType4.CodeValueFormat = "TimeSpan.Parse(\"{0}\")"; dataType4.TypeGroup = "Decimal"; dataType4.GetFormatProvider = ((CultureInfo culture) => culture.DateTimeFormat); array5[num4] = dataType4; array[10] = new DataType<IEnumerable<int>>("Type_CMS_IntegerTable", "", "{0}", (object value, IEnumerable<int> defaultValue, CultureInfo culture) => (value as IEnumerable<int>) ?? defaultValue) { DbType = SqlDbType.Structured, Hidden = true, TypeName = "Type_CMS_IntegerTable" }; array[11] = new DataType<IEnumerable<Guid>>("Type_CMS_GuidTable", "", "{0}", (object value, IEnumerable<Guid> defaultValue, CultureInfo culture) => (value as IEnumerable<Guid>) ?? defaultValue) { DbType = SqlDbType.Structured, Hidden = true, TypeName = "Type_CMS_GuidTable" }; array[12] = new DataType<IEnumerable<long>>("Type_CMS_BigIntTable", "", "{0}", (object value, IEnumerable<long> defaultValue, CultureInfo culture) => (value as IEnumerable<long>) ?? defaultValue) { DbType = SqlDbType.Structured, Hidden = true, TypeName = "Type_CMS_BigIntTable" }; array[13] = new DataType<IEnumerable<string>>("Type_CMS_StringTable", "", "{0}", (object value, IEnumerable<string> defaultValue, CultureInfo culture) => (value as IEnumerable<string>) ?? defaultValue) { DbType = SqlDbType.Structured, Hidden = true, TypeName = "Type_CMS_StringTable" }; DataTypeManager.RegisterDataTypesInternal(defaultTypes, array); bool defaultTypes2 = false; DataType[] array6 = new DataType[5]; array6[0] = new DataType<byte[]>("varbinary", "binary", "xs:base64binary", new Func<object, byte[], CultureInfo, byte[]>(ValidationHelper.GetBinary)) { Hidden = true, TypeAlias = "byte[]", SupportsTranslation = true, DbType = SqlDbType.VarBinary, TypeGroup = "Binary", VariableSize = true, DefaultSize = 50, MaxSize = 4000, HasConfigurableDefaultValue = false, AllowedObjectTypes = new string[] { "cms.systemtable", "cms.class" } }; array6[1] = new DataType<Guid>("uniqueidentifier", "file", "xs:string", new Func<object, Guid, CultureInfo, Guid>(ValidationHelper.GetGuid)) { TypeGroup = "File", DefaultValueCode = "Guid.Empty", SupportsTranslation = true, AllowAsAliasSource = false }; array6[2] = new DataType<string>("nvarchar", "text", "xs:string", new Func<object, string, CultureInfo, string>(ValidationHelper.GetString)) { TypeAlias = "string", SqlValueFormat = "N'{0}'", CodeValueFormat = "\"{0}\"", DefaultValueCode = "String.Empty", VariableSize = true, DefaultSize = 200, MaxSize = 4000, DefaultValue = "", SupportsTranslation = true, DbType = SqlDbType.NVarChar, TypeGroup = "Text" }; DataType[] array7 = array6; int num5 = 3; DataType<DateTime> dataType5 = new DataType<DateTime>("date", "date", "xs:dateTime", new Func<object, DateTime, CultureInfo, DateTime>(ValidationHelper.GetDate)); dataType5.DbType = SqlDbType.Date; dataType5.DefaultValueCode = "DateTimeHelper.ZERO_TIME"; dataType5.CodeValueFormat = "DateTime.Parse(\"{0}\")"; dataType5.SpecialDefaultValues = new List<string> { "##TODAY##" }; dataType5.TypeGroup = "DateTime"; dataType5.StringFormat = "{0:d}"; dataType5.GetFormatProvider = ((CultureInfo culture) => culture.DateTimeFormat); array7[num5] = dataType5; array6[4] = new DataType<string>("xml", "xml", "xs:string", new Func<object, string, CultureInfo, string>(ValidationHelper.GetString)) { DbType = SqlDbType.Xml, Hidden = true }; DataTypeManager.RegisterDataTypesInternal(defaultTypes2, array6); }
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2019-06-25 Bootstrap 4 - Glyphicons migration?
2019-06-25 Bootstrap 3 Glyphicons are not working
2019-06-25 WebPack Task Runner
2019-06-25 AMD - Learning JavaScript Design Patterns [Book] - O'Reilly
2019-06-25 webpack
2019-06-25 如何下载js类库
2019-06-25 Asynchronous module definition