コード例 #1
0
        public bool GenericMappingSchema_InitDB2()
        {
            void xAppendConversion_DB2(StringBuilder stringBuilder, int value) => stringBuilder.Append($"chr({value})");
            void xConvertStringToSql_DB2(StringBuilder stringBuilder, string value) => DataTools.ConvertStringToSql(stringBuilder, "||", null, xAppendConversion_DB2, value, null);


            SetDataType(typeof(string), new SqlDataType(DataType.NVarChar, typeof(string), 255));

            SetValueToSqlConverter(typeof(byte[]), (sb, dt, v) => sb.ConvertBinaryToSql_DB2((byte[])v));
            SetValueToSqlConverter(typeof(Binary), (sb, dt, v) => sb.ConvertBinaryToSql_DB2(((Binary)v).ToArray()));
            SetValueToSqlConverter(typeof(char), (sb, dt, v) => sb.ConvertCharToSql_DB2((char)v));
            SetValueToSqlConverter(typeof(DateTime), (sb, dt, v) => sb.ConvertDateTimeToSql_DB2(dt, (DateTime)v));
            SetValueToSqlConverter(typeof(Guid), (sb, dt, v) => sb.ConvertGuidToSql_DB2((Guid)v));
            SetValueToSqlConverter(typeof(string), (sb, dt, v) => xConvertStringToSql_DB2(sb, v.ToString() !));
            SetValueToSqlConverter(typeof(string), (sb, dt, v) => sb.ConvertStringToSql_DB2(v.ToString() !));
            SetValueToSqlConverter(typeof(TimeSpan), (sb, dt, v) => sb.ConvertTimeToSql_DB2((TimeSpan)v));

            SetConverter <string, DateTime>(GenericExtensions.ParseDateTime_DB2);
            return(true);
        }