System.Data.DataColumn.DataColumn C# (CSharp) Method

DataColumn() public method

Initializes a new instance of the class using the specified name, data type, expression, and value that determines whether the column is an attribute.
public DataColumn ( string columnName, Type dataType, string expr, MappingType type ) : System.Xml
columnName string
dataType Type
expr string
type MappingType
return System.Xml
        public DataColumn(string columnName, Type dataType, string expr, MappingType type)
        {
            GC.SuppressFinalize(this);
            DataCommonEventSource.Log.Trace("<ds.DataColumn.DataColumn|API> {0}, columnName='{1}', expr='{2}', type={3}", ObjectID, columnName, expr, type);

            if (dataType == null)
            {
                throw ExceptionBuilder.ArgumentNull(nameof(dataType));
            }

            StorageType typeCode = DataStorage.GetStorageType(dataType);
            if (DataStorage.ImplementsINullableValue(typeCode, dataType))
            {
                throw ExceptionBuilder.ColumnTypeNotSupported();
            }
            _columnName = columnName ?? string.Empty;

            SimpleType stype = SimpleType.CreateSimpleType(typeCode, dataType);
            if (null != stype)
            {
                SimpleType = stype;
            }
            UpdateColumnType(dataType, typeCode);

            if (!string.IsNullOrEmpty(expr)) // its a performance hit to set Expression to the empty str when we know it will come out null
            {
                Expression = expr;
            }

            _columnMapping = type;
        }

Same methods

DataColumn::DataColumn ( ) : System.Xml
DataColumn::DataColumn ( string columnName ) : System.Xml
DataColumn::DataColumn ( string columnName, Type dataType ) : System.Xml
DataColumn::DataColumn ( string columnName, Type dataType, string expr ) : System.Xml