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

CheckNotAllowNull() protected method

protected CheckNotAllowNull ( ) : void
return void
        internal protected void CheckNotAllowNull()
        {
            if (_storage == null)
            {
                return;
            }

            if (_sortIndex != null)
            {
                if (_sortIndex.IsKeyInIndex(_storage._nullValue))
                {
                    // here we do use strong typed NULL for Sql types
                    throw ExceptionBuilder.NullKeyValues(ColumnName);
                }
            }
            else
            {
                // since we do not have index, we so sequential search
                foreach (DataRow dr in _table.Rows)
                {
                    if (dr.RowState == DataRowState.Deleted)
                    {
                        continue;
                    }

                    if (!_implementsINullable)
                    {
                        if (dr[this] == DBNull.Value)
                        {
                            throw ExceptionBuilder.NullKeyValues(ColumnName);
                        }
                    }
                    else
                    {
                        if (DataStorage.IsObjectNull(dr[this]))
                        {
                            throw ExceptionBuilder.NullKeyValues(ColumnName);
                        }
                    }
                }
            }
        }