/// <summary>
        /// Creates the foreign key columns.
        /// </summary>
        private void CreateForeignKeyColumns()
        {
            // Get all foreign key columns from the database.
            if (GetDatabaseForeignKeyColumns())
            {
                List <ForeignKey> array = new List <ForeignKey>();

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

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

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

                // Add all the foreign keys.
                _tableEntity.TableEntityForeignKey = 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;
            }
        }