src/Inflatable/Sessions/Commands/SaveCommand.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="declarationBatch">The declaration 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,
            SQLHelper declarationBatch,
            IList<object> objectsSeen,
            IEnumerable<IMapping> parentMappings)
        {
            var ORMObject = @object as IORMObject;
            foreach (var ManyToOneProperty in parentMappings.SelectMany(x => x.ManyToOneProperties)
                                                             .Where(x => x.Cascade
                                                                      && (ORMObject?.PropertiesChanged0.Contains(x.Name) != false)))
            {
                var ManyToOneValue = ManyToOneProperty.GetValue(@object);
                if (ManyToOneValue is null)
                {
                    continue;
                }
                if (!(ManyToOneValue is IEnumerable ManyToOneListValue))
                {
                    Save(ManyToOneValue, source, batch, declarationBatch, objectsSeen);
                }
                else
                {
                    foreach (var Item in ManyToOneListValue)
                    {
                        Save(Item, source, batch, declarationBatch, objectsSeen);
                    }
                }
            }
        }
private void CascadeManyToOneProperties ( object @object , IMappingSource source , SQLHelper batch , SQLHelper declarationBatch , IList < object > objectsSeen , IEnumerable < IMapping > parentMappings ) { var ORMObject = @object as IORMObject ; foreach ( var ManyToOneProperty in parentMappings . SelectMany ( x => x . ManyToOneProperties ) . Where ( x => x . Cascade && ( ORMObject ? . PropertiesChanged0 . Contains ( x . Name ) != false ) ) ) { var ManyToOneValue = ManyToOneProperty . GetValue ( @object ) ; if ( ManyToOneValue is null ) { continue ; } if ( ! ( ManyToOneValue is IEnumerable ManyToOneListValue ) ) { Save ( ManyToOneValue , source , batch , declarationBatch , objectsSeen ) ; } else { foreach ( var Item in ManyToOneListValue ) { Save ( Item , source , batch , declarationBatch , objectsSeen ) ; } } } }
Cascades the many to one properties.
Cascades the many to one properties .
@object
object
source
IMappingSource
None
batch
SQLHelper
None
declarationBatch
SQLHelper
The declaration batch.
The declaration batch .
objectsSeen
IList<object>
The objects seen.
The objects seen .
parentMappings
IEnumerable<IMapping>
The parent mappings.
The parent mappings .
object
None