/// <summary>
        /// Creates the reference columns.
        /// </summary>
        private void CreateReferenceColumns()
        {
            // Get all reference columns from the database.
            if (GetDatabaseReferenceKeyColumns())
            {
                List <Reference> array = new List <Reference>();

                // For each column found in the table
                // iterate through the list and create
                // each field.
                foreach (var result in _tableRefs)
                {
                    // If the table item is not on the exclusion list.
                    if (_data.TableList.Contains(result.TableName.ToUpper(), new ToUpperComparer()) == !_tableListExclusion)
                    {
                        Reference tableEntityReference = new Reference();
                        tableEntityReference.ColumnName = result.ColumnName;
                        tableEntityReference.ColumnType = result.ColumnType;
                        tableEntityReference.Name       = result.TableName;
                        tableEntityReference.IsNullable = result.IsNullable;
                        tableEntityReference.Owner      = result.ForeignKeyOwner;

                        if (result.Precision != null && result.Precision > 0)
                        {
                            if ((result.Length <= result.Precision))
                            {
                                tableEntityReference.Length = result.Length;
                            }
                            else
                            {
                                tableEntityReference.Length = (long)result.Precision;
                            }
                        }
                        else
                        {
                            if (Common.LinqToDataTypes.GetLinqNullableType(result.ColumnType, Common.ConnectionProvider.GetConnectionDataType(_connectionDataType)))
                            {
                                tableEntityReference.Length = result.Length;
                            }
                            else
                            {
                                tableEntityReference.Length = LinqToDataTypes.DefaultLengthValue(ConnectionProvider.GetConnectionType(_connectionType));
                            }
                        }

                        // Assign the current reference.
                        array.Add(tableEntityReference);
                    }
                }

                // Add all the reference keys.
                _tableEntity.TableEntityReference = array.ToArray();
            }
        }
        /// <summary>
        /// Creates the data column.
        /// </summary>
        private void CreateDataColumns()
        {
            // Get all data columns from the database.
            if (GetDatabaseTableColumns())
            {
                // Get all primary keys.
                bool primaryKeysExist = GetDatabasePrimaryKeys();

                int          i     = 0;
                DataColumn[] array = new DataColumn[_columns.Count()];

                // For each column found in the table
                // iterate through the list and create
                // each field.
                foreach (var result in _columns)
                {
                    DataColumn tableEntityDataColumn = new DataColumn();
                    tableEntityDataColumn.IsAutoGenerated = result.IsComputed;
                    tableEntityDataColumn.Name            = result.ColumnName;

                    if (result.Precision != null && result.Precision > 0)
                    {
                        if ((result.Length <= result.Precision))
                        {
                            tableEntityDataColumn.Length = result.Length;
                        }
                        else
                        {
                            tableEntityDataColumn.Length = (long)result.Precision;
                        }
                    }
                    else
                    {
                        if (Common.LinqToDataTypes.GetLinqNullableType(result.ColumnType, Common.ConnectionProvider.GetConnectionDataType(_connectionDataType)))
                        {
                            tableEntityDataColumn.Length = result.Length;
                        }
                        else
                        {
                            tableEntityDataColumn.Length = LinqToDataTypes.DefaultLengthValue(ConnectionProvider.GetConnectionType(_connectionType));
                        }
                    }

                    tableEntityDataColumn.IsNullable   = result.ColumnNullable;
                    tableEntityDataColumn.DbType       = result.ColumnType;
                    tableEntityDataColumn.DbColumnName = result.ColumnName;

                    // If primary keys exist.
                    if (primaryKeysExist)
                    {
                        // If the current column is a primary key column.
                        if (_tablePKs.Where(k => k.PrimaryKeyName == result.ColumnName).Count() > 0)
                        {
                            tableEntityDataColumn.IsPrimaryKey = true;
                        }
                        else
                        {
                            tableEntityDataColumn.IsPrimaryKey = false;
                        }
                    }

                    // Is the primary key is seeded.
                    if (result.PrimaryKeySeed)
                    {
                        tableEntityDataColumn.IsSeeded = true;
                    }
                    else
                    {
                        tableEntityDataColumn.IsSeeded = false;
                    }

                    // If the data type is row version.
                    if (result.ColumnType.ToLower() == "timestamp")
                    {
                        tableEntityDataColumn.IsRowVersion = true;
                    }
                    else
                    {
                        tableEntityDataColumn.IsRowVersion = false;
                    }

                    // Assign the current data columns.
                    array[i++] = tableEntityDataColumn;
                }

                // Add all the data columns.
                _tableEntity.TableEntityDataColumn = array;
            }
        }