src/Misc/EFTools/EntityDesignEntityDesigner/CustomCode/Diagram/DSLDesignerNavigationHelper.cs
/// <summary>
///     Given a efobject in m-space (ie, it is defined in the mapping section of the edmx file), find the
///     closest object in the c-space (ie, defined in the conceptual schema).  We do this by looking
///     for binding objects of the current node bound to something in c-space. If there is no such object, we
///     recursively call this on efobject's parent.
/// </summary>
/// <param name="efobject"></param>
/// <returns></returns>
Given a efobject in m-space , find the
closest object in the c-space .  We do this by looking
for binding objects of the current node bound to something in c-space. If there is no such object, we
recursively call this on efobject's parent.
Given a efobject in m - space find the closest object in the c - space . We do this by looking for binding objects of the current node bound to something in c - space . If there is no such object we recursively call this on efobject ' s parent .
private static EFObject GetCSpaceEFObjectForMSpaceEFObject(EFObject mspaceEFObject)
        {
            EFObject cspaceEFObject = null;
            var o = mspaceEFObject;
            var asm = mspaceEFObject.GetParentOfType(typeof(AssociationSetMapping)) as AssociationSetMapping;
            if (asm != null)
            {
                var associationSet = asm.Name.Target;
                if (associationSet != null)
                {
                    var association = associationSet.Association.Target;
                    if (association != null)
                    {
                        Debug.Assert(
                            association.RuntimeModelRoot() is ConceptualEntityModel, "Expected association to be in C-space, but it is not!");
                        return association;
                    }
                }
            }
            var mfm = mspaceEFObject.GetParentOfType(typeof(ModificationFunctionMapping)) as ModificationFunctionMapping;
            var context = PackageManager.Package.DocumentFrameMgr.EditingContextManager.GetNewOrExistingContext(mspaceEFObject.Artifact.Uri);
            var mappingDetailsInfo = context.Items.GetValue<MappingDetailsInfo>();
            if (mfm != null)
            {
                mappingDetailsInfo.EntityMappingMode = EntityMappingModes.Functions;
            }
            else
            {
                mappingDetailsInfo.EntityMappingMode = EntityMappingModes.Tables;
            }
            while (cspaceEFObject == null
                   && o != null)
            {
                var binding = o as ItemBinding;
                var container = o as EFContainer;
                if (binding != null)
                {
                    cspaceEFObject = GetCSpaceObjectFromBinding(binding);
                }
                else if (container != null)
                {
                    foreach (var child in container.Children)
                    {
                        var b = child as ItemBinding;
                        if (b != null)
                        {
                            cspaceEFObject = GetCSpaceObjectFromBinding(b);
                            if (cspaceEFObject != null)
                            {
                                break;
                            }
                        }
                    }
                }
                if (cspaceEFObject == null)
                {
                    o = o.Parent;
                }
            }
            return cspaceEFObject;
        }
private static EFObject GetCSpaceEFObjectForMSpaceEFObject ( EFObject mspaceEFObject ) { EFObject cspaceEFObject = null ; var o = mspaceEFObject ; var asm = mspaceEFObject . GetParentOfType ( typeof ( AssociationSetMapping ) ) as AssociationSetMapping ; if ( asm != null ) { var associationSet = asm . Name . Target ; if ( associationSet != null ) { var association = associationSet . Association . Target ; if ( association != null ) { Debug . Assert ( association . RuntimeModelRoot ( ) is ConceptualEntityModel , " " ) ; return association ; } } } var mfm = mspaceEFObject . GetParentOfType ( typeof ( ModificationFunctionMapping ) ) as ModificationFunctionMapping ; var context = PackageManager . Package . DocumentFrameMgr . EditingContextManager . GetNewOrExistingContext ( mspaceEFObject . Artifact . Uri ) ; var mappingDetailsInfo = context . Items . GetValue < MappingDetailsInfo > ( ) ; if ( mfm != null ) { mappingDetailsInfo . EntityMappingMode = EntityMappingModes . Functions ; } else { mappingDetailsInfo . EntityMappingMode = EntityMappingModes . Tables ; } while ( cspaceEFObject == null && o != null ) { var binding = o as ItemBinding ; var container = o as EFContainer ; if ( binding != null ) { cspaceEFObject = GetCSpaceObjectFromBinding ( binding ) ; } else if ( container != null ) { foreach ( var child in container . Children ) { var b = child as ItemBinding ; if ( b != null ) { cspaceEFObject = GetCSpaceObjectFromBinding ( b ) ; if ( cspaceEFObject != null ) { break ; } } } } if ( cspaceEFObject == null ) { o = o . Parent ; } } return cspaceEFObject ; }
Given a efobject in m-space (ie, it is defined in the mapping section of the edmx file), find the
closest object in the c-space (ie, defined in the conceptual schema).
Given a efobject in m - space ( ie it is defined in the mapping section of the edmx file ) find the closest object in the c - space ( ie defined in the conceptual schema ) .
// see if this m-space object has a parent of an association set mapping. // see if this is a node that requires the function view in the mapping pane // default case, walk up the model looking for node that has a binding bound to something in c-space.   // see if this binding is bound to something in c-space // see if any direct children are bindings bound to something in c-space // check every binding to see if it is bound to seomthing in cspace // break out of the for loop
None
mspaceEFObject
EFObject
efobject
None