Exemple #1
0
        public override bool Equals(object obj)
        {
            if ((obj as EntityColumn) == null)
            {
                return(false);
            }

            EntityColumn column = (EntityColumn)obj;

            return(column.Name == Name);
        }
Exemple #2
0
        public void AddDataRow(IEntity item)
        {
            List <object> rowData = item.GetPropertyValues();
            DataRow       dataRow = DataTable.NewRow();

            for (int i = 0; i < rowData.Count; i++)
            {
                EntityColumn column = EntityColumns[i];
                object       data   = rowData[i];

                column.UpdateDataRow(dataRow, data);
            }

            DataTable.Rows.Add(dataRow);
            dataRows.Add(item, dataRow);
        }
Exemple #3
0
        private void InitialiseEntityColumns(AttributeWrapper attributes)
        {
            foreach (ColumnAttribute columnAttribute in attributes.ColumnAttributes)
            {
                EntityColumn column     = new EntityColumn(columnAttribute, this);
                DataColumn   dataColumn = column.DataColumn;

                if (attributes.ColumnForeignKeys.ContainsKey(columnAttribute))
                {
                    ForeignKeyAttribute key = attributes.ColumnForeignKeys[columnAttribute];

                    column.ForeignKeyTableMapping = key.ForeignTable;
                    column.KeyType = (byte)KeyTypes.ForeignKey;

                    foreignKeyColumns.Add(column);
                    foreignKeyColumnsDict.Add(column.ForeignKeyTableMapping, column);
                }

                if (attributes.ColumnPrimaryKeys.ContainsKey(columnAttribute))
                {
                    PrimaryKeyAttribute key = attributes.ColumnPrimaryKeys[columnAttribute];

                    column.KeyType = (byte)KeyTypes.PrimaryKey;

                    primaryKeyColumn = column;
                }

                /*
                 * Bulk inserts can only be performed on data that is mapped to a physical column in the database. These are
                 * represented by instances of the EntityColumn class, and contain specific methods which determine key type
                 * etc.
                 */

                if (!column.IsPrimaryKey())
                {
                    DataTable.Columns.Add(dataColumn);
                }

                EntityColumns.Add(column);
                Columns.Add(column);
            }
        }