Ejemplo n.º 1
0
 void DependentValueChanged(object sender, ValueChangedEventArgs e)
 {
     if (!DependentColumns.Contains(e.Column))
     {
         return;
     }
     foreach (var row in GetAffectedRows(e.Row, (Table)sender))
     {
         OnRowInvalidated(row);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///     Gets an operation to create an index on the foreign key column(s).
        /// </summary>
        /// <returns> An operation to add the index. </returns>
        public virtual CreateIndexOperation CreateCreateIndexOperation()
        {
            var createIndexOperation
                = new CreateIndexOperation
                {
                Table = DependentTable
                };

            DependentColumns.Each(c => createIndexOperation.Columns.Add(c));

            return(createIndexOperation);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets an operation to drop the associated index on the foreign key column(s).
        /// </summary>
        /// <returns> An operation to drop the index. </returns>
        public virtual DropIndexOperation CreateDropIndexOperation()
        {
            var dropIndexOperation
                = new DropIndexOperation(_inverse.CreateCreateIndexOperation())
                {
                Table = DependentTable
                };

            DependentColumns.Each(c => dropIndexOperation.Columns.Add(c));

            return(dropIndexOperation);
        }
Ejemplo n.º 4
0
        ///<summary>Unregisters event handlers registered in Register.</summary>
        public override void Unregister(Table table)
        {
            var rc = GetRowCollection(table);

            rc.RowAdded   -= DependentRowAdded;
            rc.RowRemoved -= DependentRowRemoved;

            if (DependentColumns.Any())
            {
                rc.ValueChanged -= DependentValueChanged;
            }

            foreach (var child in NestedDependencies)
            {
                child.Unregister(table);
            }
        }
Ejemplo n.º 5
0
        private void SetMultiplicities()
        {
            _assocationType.SourceEnd.RelationshipMultiplicity = RelationshipMultiplicity.ZeroOrOne;
            _assocationType.TargetEnd.RelationshipMultiplicity = RelationshipMultiplicity.Many;

            var dependentTable = _assocationType.TargetEnd.GetEntityType();

            if (dependentTable.DeclaredKeyProperties.Count() == DependentColumns.Count() &&
                dependentTable.DeclaredKeyProperties.All(DependentColumns.Contains))
            {
                _assocationType.SourceEnd.RelationshipMultiplicity = RelationshipMultiplicity.One;
                _assocationType.TargetEnd.RelationshipMultiplicity = RelationshipMultiplicity.ZeroOrOne;
            }
            else if (!DependentColumns.Any(p => p.Nullable))
            {
                _assocationType.SourceEnd.RelationshipMultiplicity = RelationshipMultiplicity.One;
            }
        }