Example #1
0
        public TableRelation(TableSymbol parentTable, IReadOnlyCollection <ColumnSymbol> parentColumns, TableSymbol childTable, IReadOnlyCollection <ColumnSymbol> childColumns)
        {
            if (parentColumns == null)
            {
                throw new ArgumentNullException(nameof(parentColumns));
            }

            if (childColumns == null)
            {
                throw new ArgumentNullException(nameof(childColumns));
            }

            if (parentColumns.Count == 0)
            {
                throw new ArgumentException(Resources.ParentColumnsMustContainAtLeastOneColumn, nameof(parentColumns));
            }

            if (childColumns.Count != parentColumns.Count)
            {
                throw new ArgumentException(Resources.ChildColumnsMustHaveSameSizeAsParentColumns, nameof(childColumns));
            }

            if (parentColumns.Any(c => !parentTable.Columns.Contains(c)))
            {
                throw new ArgumentException(Resources.AllParentColumnsMustBelongToSameTable, nameof(parentColumns));
            }

            if (childColumns.Any(c => !childTable.Columns.Contains(c)))
            {
                throw new ArgumentException(Resources.AllChildColumnsMustBelongToSameTable, nameof(childColumns));
            }

            ParentTable   = parentTable;
            ParentColumns = parentColumns.ToImmutableArray();
            ChildTable    = childTable;
            ChildColumns  = childColumns.ToImmutableArray();
        }
Example #2
0
 internal TableInstanceSymbol(string name, TableSymbol table, Func <TableInstanceSymbol, ColumnSymbol, ValueSlot> valueFactory)
     : base(name)
 {
     Table           = table;
     ColumnInstances = table.Columns.Select(c => new TableColumnInstanceSymbol(this, c, valueFactory)).ToImmutableArray();
 }
Example #3
0
 internal TableInstanceSymbol(string name, TableSymbol table, ValueSlotFactory valueFactory)
     : this(name, table, (ti, c) => valueFactory.CreateNamed($"{ti.Name}.{c.Name}", c.Type))
 {
 }