src/Misc/EFTools/EntityDesign/UI/ViewModels/MappingDetails/Association/MappingAssociationSet.cs
// <summary>
//     NOTE: The association set mapping view model doesn't keep a reference to the mapping model item. Instead, it
//     keeps it to the AssociationSet and then it can find the AssociationSetMapping as an anti-dep.  We don't need to clear
//     or set the ModelItem property.
// </summary>
The association set mapping view model doesn't keep a reference to the mapping model item. Instead, it
keeps it to the AssociationSet and then it can find the AssociationSetMapping as an anti-dep.  We don't need to clear
or set the ModelItem property.
The association set mapping view model doesn ' t keep a reference to the mapping model item . Instead it keeps it to the AssociationSet and then it can find the AssociationSetMapping as an anti - dep . We don ' t need to clear or set the ModelItem property .
internal override void CreateModelItem(CommandProcessorContext cpc, EditingContext context, EFElement underlyingModelItem)
        {
            Debug.Assert(context != null, "The context argument cannot be null");
            Debug.Assert(AssociationSet.AssociationSetMapping == null, "Don't call this method if we already have a mapping");
            Debug.Assert(underlyingModelItem != null, "The underlyingModelItem cannot be null");
            var storeEntityType = underlyingModelItem as EntityType;
            Debug.Assert(
                storeEntityType != null,
                "underlyingModelItem must be of type EntityType, actual type = " + underlyingModelItem.GetType().FullName);
            Debug.Assert(!storeEntityType.EntityModel.IsCSDL, "The storageEntityType must not be a CSDL EntityType");
            Context = context;
            if (cpc == null)
            {
                cpc = new CommandProcessorContext(
                    Context, EfiTransactionOriginator.MappingDetailsOriginatorId, Resources.Tx_CreateAssociationSetMapping);
            }
            var cmd1 = new CreateAssociationSetMappingCommand(MappingAssociation.Association, storeEntityType);
            var cmd2 = new DelegateCommand(
                () =>
                    {
                        Parent.AddChild(this);
                        foreach (var child in Children)
                        {
                            var end = child as MappingAssociationSetEnd;
                            if (end != null)
                            {
                                foreach (var child2 in end.Children)
                                {
                                    var mesp = child2 as MappingEndScalarProperty;
                                    if (mesp != null)
                                    {
                                        var tableColumn =
                                            MappingAssociationSet.StorageEntityType.GetFirstNamedChildByLocalName(mesp.Property, true) as
                                            Property;
                                        if (tableColumn != null)
                                        {
                                            mesp.CreateModelItem(cpc, _context, tableColumn);
                                        }
                                    }
                                }
                            }
                        }
                    });
            var cp = new CommandProcessor(cpc);
            cp.EnqueueCommand(cmd1);
            cp.EnqueueCommand(cmd2);
            cp.Invoke();
        }
internal override void CreateModelItem ( CommandProcessorContext cpc , EditingContext context , EFElement underlyingModelItem ) { Debug . Assert ( context != null , " " ) ; Debug . Assert ( AssociationSet . AssociationSetMapping == null , " " ) ; Debug . Assert ( underlyingModelItem != null , " " ) ; var storeEntityType = underlyingModelItem as EntityType ; Debug . Assert ( storeEntityType != null , " " + underlyingModelItem . GetType ( ) . FullName ) ; Debug . Assert ( ! storeEntityType . EntityModel . IsCSDL , " " ) ; Context = context ; if ( cpc == null ) { cpc = new CommandProcessorContext ( Context , EfiTransactionOriginator . MappingDetailsOriginatorId , Resources . Tx_CreateAssociationSetMapping ) ; } var cmd1 = new CreateAssociationSetMappingCommand ( MappingAssociation . Association , storeEntityType ) ; var cmd2 = new DelegateCommand ( ( ) => { Parent . AddChild ( this ) ; foreach ( var child in Children ) { var end = child as MappingAssociationSetEnd ; if ( end != null ) { foreach ( var child2 in end . Children ) { var mesp = child2 as MappingEndScalarProperty ; if ( mesp != null ) { var tableColumn = MappingAssociationSet . StorageEntityType . GetFirstNamedChildByLocalName ( mesp . Property , true ) as Property ; if ( tableColumn != null ) { mesp . CreateModelItem ( cpc , _context , tableColumn ) ; } } } } } } ) ; var cp = new CommandProcessor ( cpc ) ; cp . EnqueueCommand ( cmd1 ) ; cp . EnqueueCommand ( cmd2 ) ; cp . Invoke ( ) ; }
NOTE: The association set mapping view model doesn't keep a reference to the mapping model item.
NOTE : The association set mapping view model doesn ' t keep a reference to the mapping model item .
// create a context if we weren't passed one // create the item // now try and do some match ups by name // now make the change
cpc
CommandProcessorContext
context
EditingContext
underlyingModelItem
EFElement