src/Misc/EFTools/EntityDesign/UI/ViewModels/MappingDetails/Table/MappingScalarProperty.cs
// <summary>
//     The mapping view model contains a MappingScalarProperty for every column in the table.  The user can clear out the
//     underlying scalar property, but that doesn't remove or add the MappingScalarProperty.  We need the placeholder
//     in the view model to show the nodes in the Trid even if there isn't a mapping.  Thus, we don't need to call
//     this.Parent.AddChild(this) since its already there.
// </summary>
The mapping view model contains a MappingScalarProperty for every column in the table.  The user can clear out the
underlying scalar property, but that doesn't remove or add the MappingScalarProperty.  We need the placeholder
in the view model to show the nodes in the Trid even if there isn't a mapping.  Thus, we don't need to call
this.Parent.AddChild(this) since its already there.
The mapping view model contains a MappingScalarProperty for every column in the table . The user can clear out the underlying scalar property but that doesn ' t remove or add the MappingScalarProperty . We need the placeholder in the view model to show the nodes in the Trid even if there isn ' t a mapping . Thus we don ' t need to call this . Parent . AddChild ( this ) since its already there .
internal void CreateModelItem(CommandProcessorContext cpc, EditingContext context, List<Property> propertiesChain)
        {
            Debug.Assert(propertiesChain != null, "The propertiesChain cannot be null");
            Debug.Assert(context != null, "The context argument cannot be null");
            Debug.Assert(ScalarProperty == null, "Don't call this method if we already have a ModelItem");
            Debug.Assert(MappingStorageEntityType.StorageEntityType != null, "The parent item isn't set up correctly");
            Debug.Assert(propertiesChain.Count > 0, "propertiesChain cannot be empty");
            Context = context;
            EntityType entityType = MappingConceptualEntityType.ConceptualEntityType;
            EntityType table = MappingStorageEntityType.StorageEntityType;
            var tableColumn = table.GetFirstNamedChildByLocalName(ColumnName) as Property;
            Debug.Assert(tableColumn != null, "Failed looking up table column for ScalarProperty.");
            if (tableColumn == null)
            {
                return;
            }
            try
            {
                if (cpc == null)
                {
                    cpc = new CommandProcessorContext(
                        Context, EfiTransactionOriginator.MappingDetailsOriginatorId, Resources.Tx_CreateScalarProperty);
                }
                var cmd = new CreateFragmentScalarPropertyTreeCommand(entityType, propertiesChain, tableColumn);
                cmd.PostInvokeEvent += (o, eventsArgs) =>
                    {
                        var sp = cmd.ScalarProperty;
                        Debug.Assert(sp != null, "CreateFragmentScalarPropertyTreeCommand failed to create ScalarProperty");
                        ModelItem = sp;
                    };
                var cp = new CommandProcessor(cpc, cmd);
                cp.Invoke();
            }
            catch
            {
                ModelItem = null;
                throw;
            }
        }
internal void CreateModelItem ( CommandProcessorContext cpc , EditingContext context , List < Property > propertiesChain ) { Debug . Assert ( propertiesChain != null , " " ) ; Debug . Assert ( context != null , " " ) ; Debug . Assert ( ScalarProperty == null , " " ) ; Debug . Assert ( MappingStorageEntityType . StorageEntityType != null , " " ) ; Debug . Assert ( propertiesChain . Count > 0 , " " ) ; Context = context ; EntityType entityType = MappingConceptualEntityType . ConceptualEntityType ; EntityType table = MappingStorageEntityType . StorageEntityType ; var tableColumn = table . GetFirstNamedChildByLocalName ( ColumnName ) as Property ; Debug . Assert ( tableColumn != null , " " ) ; if ( tableColumn == null ) { return ; } try { if ( cpc == null ) { cpc = new CommandProcessorContext ( Context , EfiTransactionOriginator . MappingDetailsOriginatorId , Resources . Tx_CreateScalarProperty ) ; } var cmd = new CreateFragmentScalarPropertyTreeCommand ( entityType , propertiesChain , tableColumn ) ; cmd . PostInvokeEvent += ( o , eventsArgs ) => { var sp = cmd . ScalarProperty ; Debug . Assert ( sp != null , " " ) ; ModelItem = sp ; } ; var cp = new CommandProcessor ( cpc , cmd ) ; cp . Invoke ( ) ; } catch { ModelItem = null ; throw ; } }
The mapping view model contains a MappingScalarProperty for every column in the table.
The mapping view model contains a MappingScalarProperty for every column in the table .
// local shortcuts // find the s-side property based on the value stored in this.ColumnName // now make the change // fix up our view model (we don't have to add this to the parent's children collection // because we created a placeholder row already for every column in the table)
cpc
CommandProcessorContext
context
EditingContext
propertiesChain
List<Property>