Ejemplo n.º 1
0
 /// <summary>
 /// Ctor.
 /// </summary>
 /// <param name="metadataOriginEnum">defines how to obtain output columnn metadata</param>
 /// <param name="columnCaseConversionEnum">defines if to change case on output columns</param>
 /// <param name="dataTypesMapping">The data types mapping.</param>
 public ColumnSettings(ConfigurationDBRef.MetadataOriginEnum metadataOriginEnum,
                       ConfigurationDBRef.ColumnChangeCaseEnum columnCaseConversionEnum,
                       IDictionary <Type, Type> dataTypesMapping)
 {
     this.metadataOriginEnum       = metadataOriginEnum;
     this.columnCaseConversionEnum = columnCaseConversionEnum;
     this.dataTypesMapping         = dataTypesMapping;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Compiles the schema table.
        /// </summary>
        /// <param name="schemaTable">The schema table.</param>
        /// <param name="columnSettings">The column settings.</param>
        /// <returns></returns>
        protected virtual IDictionary <string, DBOutputTypeDesc> CompileSchemaTable(
            DataTable schemaTable,
            ColumnSettings columnSettings)
        {
            IDictionary <String, DBOutputTypeDesc> outputProperties = new Dictionary <String, DBOutputTypeDesc>();

            foreach (DataRow dataRow in schemaTable.Rows)
            {
                var canBeNull   = (Boolean)dataRow["AllowDBNull"];
                var columnName  = (String)dataRow["ColumnName"];
                var columnType  = GetColumnType(dataRow);
                var sqlTypeName = GetColumnSqlType(dataRow);
                //if (canBeNull) {
                //    columnType = columnType.GetBoxedType();
                //}

                // Address column case management
                ConfigurationDBRef.ColumnChangeCaseEnum caseEnum = columnSettings.ColumnCaseConversionEnum;
                switch (caseEnum)
                {
                case ConfigurationDBRef.ColumnChangeCaseEnum.LOWERCASE:
                    columnName = columnName.ToLower();
                    break;

                case ConfigurationDBRef.ColumnChangeCaseEnum.UPPERCASE:
                    columnName = columnName.ToUpper();
                    break;
                }

                // Setup type binding
                DatabaseTypeBinding binding = null;

                // Check the typeBinding; the typeBinding tells us if we are
                // converting the resultant type from the dataType that has been
                // provided to us into a different type.

                //if (columnSettings.SqlTypeBinding != null)
                //{
                //    String typeBinding = columnSettings.SqlTypeBinding.Get(columnType);
                //    if (typeBinding != null)
                //    {
                //        binding = DatabaseTypeEnum.GetEnum(typeBinding).Binding;
                //    }
                //}

                DBOutputTypeDesc outputDesc = new DBOutputTypeDesc(sqlTypeName, columnType, binding);
                outputProperties[columnName] = outputDesc;
            }

            return(outputProperties);
        }