src/Inflatable/Sessions/Commands/DeleteCommand.cs
/// <summary>
/// Cascades the many to one properties.
/// </summary>
/// <param name="object">The object.</param>
/// <param name="source">The source.</param>
/// <param name="batch">The batch.</param>
/// <param name="objectsSeen">The objects seen.</param>
/// <param name="ParentMappings">The parent mappings.</param>
Cascades the many to one properties.
Cascades the many to one properties .
private void CascadeManyToOneProperties(object @object, IMappingSource source, SQLHelper batch, IList<object> objectsSeen, IEnumerable<Inflatable.Interfaces.IMapping> ParentMappings)
        {
            foreach (var ManyToOneProperty in ParentMappings.SelectMany(x => x.ManyToOneProperties).Where(x => x.Cascade))
            {
                var ManyToOneValue = ManyToOneProperty.GetValue(@object);
                if (ManyToOneValue != null)
                {
                    if (ManyToOneValue is IList ManyToOneValueList)
                    {
                        var FinalList = new List<object>();
                        for (int x = 0, ManyToManyValueListCount = ManyToOneValueList.Count; x < ManyToManyValueListCount; ++x)
                        {
                            var Item = ManyToOneValueList[x];
                            FinalList.Add(Item);
                        }
                        for (int x = 0, FinalListCount = FinalList.Count; x < FinalListCount; ++x)
                        {
                            var Item = FinalList[x];
                            Delete(Item, source, batch, objectsSeen);
                        }
                    }
                    else
                    {
                        Delete(ManyToOneValue, source, batch, objectsSeen);
                    }
                }
            }
        }
private void CascadeManyToOneProperties ( object @object , IMappingSource source , SQLHelper batch , IList < object > objectsSeen , IEnumerable < Inflatable . Interfaces . IMapping > ParentMappings ) { foreach ( var ManyToOneProperty in ParentMappings . SelectMany ( x => x . ManyToOneProperties ) . Where ( x => x . Cascade ) ) { var ManyToOneValue = ManyToOneProperty . GetValue ( @object ) ; if ( ManyToOneValue != null ) { if ( ManyToOneValue is IList ManyToOneValueList ) { var FinalList = new List < object > ( ) ; for ( int x = 0 , ManyToManyValueListCount = ManyToOneValueList . Count ; x < ManyToManyValueListCount ; ++ x ) { var Item = ManyToOneValueList [ x ] ; FinalList . Add ( Item ) ; } for ( int x = 0 , FinalListCount = FinalList . Count ; x < FinalListCount ; ++ x ) { var Item = FinalList [ x ] ; Delete ( Item , source , batch , objectsSeen ) ; } } else { Delete ( ManyToOneValue , source , batch , objectsSeen ) ; } } } }
Cascades the many to one properties.
Cascades the many to one properties .
@object
object
source
IMappingSource
None
batch
SQLHelper
None
objectsSeen
IList<object>
The objects seen.
The objects seen .
ParentMappings
IEnumerable<Inflatable.Interfaces.IMapping>
The parent mappings.
The parent mappings .
object
None