コード例 #1
0
        /// <summary>
        ///     This must be implemented by derived clases who have lists of values.
        /// </summary>
        internal virtual Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
            return(lov);
        }
コード例 #2
0
        /// <summary>
        ///     Returns list of all s-side functions
        /// </summary>
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.FirstColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.FirstColumn)
            {
                var functionImport = FunctionImportMapping.FunctionImportName.Target;
                Debug.Assert(functionImport != null, "Couldn't find FunctionImport binding");
                if (functionImport != null)
                {
                    var storageModel = EFExtensions.StorageModel(functionImport.Artifact);

                    foreach (var function in storageModel.Functions())
                    {
                        // add the Function to the list
                        lov.Add(new MappingLovEFElement(function, function.DisplayName), function.DisplayName);
                    }

                    return(lov);
                }
            }

            return(base.GetListOfValues(type));
        }
コード例 #3
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.FirstColumn)
            {
                BaseEntityModel storageModel = null;
                if (AssociationSet != null
                    &&
                    AssociationSet.AssociationSetMapping != null)
                {
                    var table = GetTable();
                    storageModel = table.EntityModel as StorageEntityModel;
                }
                else
                {
                    // this is a creator node, so get the list from the artifact
                    var assoc = MappingAssociation.Association;
                    storageModel = assoc.Artifact.StorageModel();
                }

                if (AssociationSet != null
                    &&
                    AssociationSet.AssociationSetMapping != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (storageModel.EntityTypeCount == 0)
                {
                    if (AssociationSet == null
                        ||
                        AssociationSet.AssociationSetMapping == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var entityType in storageModel.EntityTypes())
                    {
                        lov.Add(new MappingLovEFElement(entityType, entityType.DisplayName), entityType.DisplayName);
                    }
                }

                return(lov);
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return(base.GetListOfValues(type));
        }
コード例 #4
0
        /// <summary>
        ///     Utility method. If already have a MappingLovEFElement just return it. If not
        ///     then lookup the MappingLovEFElement using the string and ListOfValuesType.
        ///     This latter situation means that a user has used the keyboard to select
        ///     a value from a drop-down which has come through to here as text.
        /// </summary>
        internal MappingLovEFElement GetLovElementFromLovElementOrString(
            MappingLovEFElement lovElement, string lovDisplayName, ListOfValuesCollection lovType)
        {
            if (lovElement != null)
            {
                return(lovElement);
            }

            return(FindMappingLovElement(lovDisplayName, lovType));
        }
コード例 #5
0
ファイル: MappingScalarProperty.cs プロジェクト: phekmat/ef6
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var entityType = MappingConceptualEntityType.ConceptualEntityType;
                var properties = new List <Property>();

                // for TPT, show keys for the top-most base type
                if (entityType.HasResolvableBaseType)
                {
                    if (InheritanceMappingStrategy.TablePerType == ModelHelper.DetermineCurrentInheritanceStrategy(entityType))
                    {
                        // for TPT, show keys for the top-most base type
                        EntityType topMostBaseType = entityType.ResolvableTopMostBaseType;
                        properties.AddRange(topMostBaseType.ResolvableKeys);
                    }
                }

                // also show all properties of the current entity
                properties.AddRange(entityType.Properties());

                if (ScalarProperty != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (ScalarProperty == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var prop in properties)
                    {
                        ColumnUtils.AddPropertyToListOfValues(lov, prop, null);
                    }
                }

                return(lov);
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return(base.GetListOfValues(type));
        }
コード例 #6
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.FirstColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.FirstColumn)
            {
                StorageEntityModel storageModel = null;
                if (Function != null)
                {
                    storageModel = Function.EntityModel;
                }
                else
                {
                    // this is a creator node, so get the list from the artifact
                    var entity = MappingFunctionEntityType.ModelItem as EntityType;
                    storageModel = entity.Artifact.StorageModel();
                }

                if (Function != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                var functions = new List <Function>();
                functions.AddRange(storageModel.Functions());
                if (functions.Count == 0)
                {
                    if (Function == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var func in functions)
                    {
                        // adding the Function to the list
                        lov.Add(new MappingLovEFElement(func, func.DisplayName), func.DisplayName);
                    }
                }

                return(lov);
            }

            return(base.GetListOfValues(type));
        }
コード例 #7
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.ThirdColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var properties = new List <Property>();

                var entityType           = MappingFunctionEntityType.EntityType;
                var conceptualEntityType = entityType as ConceptualEntityType;

                if (conceptualEntityType != null)
                {
                    properties.AddRange(conceptualEntityType.SafeInheritedAndDeclaredProperties);
                }
                else
                {
                    properties.AddRange(entityType.Properties());
                }

                if (ResultBinding != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (ResultBinding == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var prop in properties)
                    {
                        var displayName = ColumnUtils.BuildPropertyDisplay(prop.LocalName.Value, prop.TypeName);
                        lov.Add(new MappingLovEFElement(prop, displayName), displayName);
                    }
                }

                return(lov);
            }

            return(base.GetListOfValues(type));
        }
コード例 #8
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.ThirdColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var table      = MappingAssociationSet.GetTable();
                var properties = new List <Property>();
                if (table != null)
                {
                    properties.AddRange(table.Properties());
                }

                // we aren't filtering this list, show all columns of the table
                if (ScalarProperty != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (ScalarProperty == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    foreach (var prop in properties)
                    {
                        var displayName = ColumnUtils.BuildPropertyDisplay(prop.LocalName.Value, prop.TypeName);
                        lov.Add(new MappingLovEFElement(prop, displayName), displayName);
                    }
                }

                return(lov);
            }

            return(base.GetListOfValues(type));
        }
コード例 #9
0
ファイル: MappingEFElement.cs プロジェクト: phekmat/ef6
        // <summary>
        //     Looks for an LOV Element in this item's list of values.
        // </summary>
        // <param name="lovDisplayName">What to look for</param>
        // <param name="lovType">Which LOV collection to search</param>
        // <returns>If none are found it will return a null item.</returns>
        internal MappingLovEFElement FindMappingLovElement(string lovDisplayName, ListOfValuesCollection lovType)
        {
            MappingLovEFElement mappingLovElement = null;
            Debug.Assert(lovDisplayName != null, "Null lovDisplayName in FindMappingLovElement()");
            if (lovDisplayName != null)
            {
                var lov = GetListOfValues(lovType);
                foreach (var entry in lov)
                {
                    if (lovDisplayName == entry.Value)
                    {
                        mappingLovElement = entry.Key;
                        break;
                    }
                }

                Debug.Assert(
                    mappingLovElement != null,
                    "Could not find MappingLovElement for lovDisplayName " + lovDisplayName + ", lovType " + lovType.ToString());
            }

            return mappingLovElement;
        }
コード例 #10
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.FirstColumn)
            {
                BaseEntityModel storageModel = null;
                if (AssociationSet != null
                    &&
                    AssociationSet.AssociationSetMapping != null)
                {
                    var table = GetTable();
                    storageModel = table.EntityModel as StorageEntityModel;
                }
                else
                {
                    // this is a creator node, so get the list from the artifact
                    var assoc = MappingAssociation.Association;
                    storageModel = assoc.Artifact.StorageModel();
                }

                if (AssociationSet != null
                    &&
                    AssociationSet.AssociationSetMapping != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (storageModel.EntityTypeCount == 0)
                {
                    if (AssociationSet == null
                        ||
                        AssociationSet.AssociationSetMapping == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var entityType in storageModel.EntityTypes())
                    {
                        lov.Add(new MappingLovEFElement(entityType, entityType.DisplayName), entityType.DisplayName);
                    }
                }

                return lov;
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return base.GetListOfValues(type);
        }
コード例 #11
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var entityType = MappingConceptualEntityType.ConceptualEntityType;
                var properties = new List<Property>();

                // for TPT, show keys for the top-most base type
                if (entityType.HasResolvableBaseType)
                {
                    if (InheritanceMappingStrategy.TablePerType == ModelHelper.DetermineCurrentInheritanceStrategy(entityType))
                    {
                        // for TPT, show keys for the top-most base type
                        EntityType topMostBaseType = entityType.ResolvableTopMostBaseType;
                        properties.AddRange(topMostBaseType.ResolvableKeys);
                    }
                }

                // also show all properties of the current entity
                properties.AddRange(entityType.Properties());

                if (ScalarProperty != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (ScalarProperty == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var prop in properties)
                    {
                        ColumnUtils.AddPropertyToListOfValues(lov, prop, null);
                    }
                }

                return lov;
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return base.GetListOfValues(type);
        }
コード例 #12
0
        // <summary>
        //     Looks for an LOV Element in this item's list of values.
        // </summary>
        // <param name="lovDisplayName">What to look for</param>
        // <param name="lovType">Which LOV collection to search</param>
        // <returns>If none are found it will return a null item.</returns>
        internal MappingLovEFElement FindMappingLovElement(string lovDisplayName, ListOfValuesCollection lovType)
        {
            MappingLovEFElement mappingLovElement = null;
            Debug.Assert(lovDisplayName != null, "Null lovDisplayName in FindMappingLovElement()");
            if (lovDisplayName != null)
            {
                var lov = GetListOfValues(lovType);
                foreach (var entry in lov)
                {
                    if (lovDisplayName == entry.Value)
                    {
                        mappingLovElement = entry.Key;
                        break;
                    }
                }

                Debug.Assert(
                    mappingLovElement != null,
                    "Could not find MappingLovElement for lovDisplayName " + lovDisplayName + ", lovType " + lovType.ToString());
            }

            return mappingLovElement;
        }
コード例 #13
0
        // <summary>
        //     Utility method. If already have a MappingLovEFElement just return it. If not
        //     then lookup the MappingLovEFElement using the string and ListOfValuesType.
        //     This latter situation means that a user has used the keyboard to select
        //     a value from a drop-down which has come through to here as text.
        // </summary>
        internal MappingLovEFElement GetLovElementFromLovElementOrString(
            MappingLovEFElement lovElement, string lovDisplayName, ListOfValuesCollection lovType)
        {
            if (lovElement != null)
            {
                return lovElement;
            }

            return FindMappingLovElement(lovDisplayName, lovType);
        }
コード例 #14
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.FirstColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.FirstColumn)
            {
                StorageEntityModel storageModel = null;
                if (Function != null)
                {
                    storageModel = Function.EntityModel;
                }
                else
                {
                    // this is a creator node, so get the list from the artifact
                    var entity = MappingFunctionEntityType.ModelItem as EntityType;
                    storageModel = entity.Artifact.StorageModel();
                }

                if (Function != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                var functions = new List<Function>();
                functions.AddRange(storageModel.Functions());
                if (functions.Count == 0)
                {
                    if (Function == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var func in functions)
                    {
                        // adding the Function to the list
                        lov.Add(new MappingLovEFElement(func, func.DisplayName), func.DisplayName);
                    }
                }

                return lov;
            }

            return base.GetListOfValues(type);
        }
コード例 #15
0
 // <summary>
 //     This must be implemented by derived clases who have lists of values.
 // </summary>
 internal virtual Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
 {
     var lov = new Dictionary<MappingLovEFElement, string>();
     lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
     return lov;
 }
コード例 #16
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var entityType = MappingFunctionEntityType.EntityType;
                var cet = entityType as ConceptualEntityType;

                Debug.Assert(entityType == null || cet != null, "EntityType is not ConceptualEntityType");

                var propsFromSelf = new List<Property>();
                var propsFromNav = new Dictionary<NavigationProperty, HashSet<Property>>();

                // show keys for the top-most base type
                if (cet.HasResolvableBaseType)
                {
                    propsFromSelf.AddRange(entityType.ResolvableKeys);
                }

                // show all properties of the entity
                propsFromSelf.AddRange(cet.SafeInheritedAndDeclaredProperties);

                // bug 568863: we need to show any "inherited" navigation properties as well
                foreach (var selfOrBaseType in cet.SafeSelfAndBaseTypes)
                {
                    // add properties for every type referenced by a navigation property
                    foreach (var nav in selfOrBaseType.NavigationProperties())
                    {
                        if (nav.FromRole.Status == BindingStatus.Known
                            && nav.FromRole.Target.Type.Status == BindingStatus.Known
                            && nav.ToRole.Status == BindingStatus.Known
                            && nav.ToRole.Target.Type.Status == BindingStatus.Known
                            && nav.ToRole.Target.Multiplicity.Value != ModelConstants.Multiplicity_Many)
                        {
                            ConceptualEntityType other = null;
                            if (nav.FromRole.Target.Type.Target == selfOrBaseType)
                            {
                                other = nav.ToRole.Target.Type.Target as ConceptualEntityType;
                            }
                            else
                            {
                                other = nav.FromRole.Target.Type.Target as ConceptualEntityType;
                            }

                            if (!propsFromNav.ContainsKey(nav))
                            {
                                propsFromNav[nav] = new HashSet<Property>();
                            }

                            // bug 568863, only include keys from reference types
                            foreach (var key in other.ResolvableTopMostBaseType.ResolvableKeys)
                            {
                                if (!propsFromNav[nav].Contains(key))
                                {
                                    propsFromNav[nav].Add(key);
                                }
                            }
                        }
                    }
                }

                if (ScalarProperty != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (propsFromSelf.Count == 0
                    && propsFromNav.Count == 0)
                {
                    if (ScalarProperty == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    var displayName = String.Empty;

                    // add those remaining in our list
                    // Note: properties (even simple ScalarProperties that are not part of a ComplexProperty) are
                    //       added to the lov as a List<Property> whereas properties from the other end of a
                    //       NavigationProperty are added as a Property. This allows us to tell them apart (see
                    //       PropertyColumn.SetValue())
                    foreach (var prop in propsFromSelf)
                    {
                        ColumnUtils.AddPropertyToListOfValues(lov, prop, null);
                    }

                    var propsFromNavEnum = propsFromNav.GetEnumerator();
                    while (propsFromNavEnum.MoveNext())
                    {
                        foreach (var prop in propsFromNavEnum.Current.Value)
                        {
                            displayName = string.Format(
                                CultureInfo.CurrentCulture, "{0}.{1}",
                                propsFromNavEnum.Current.Key.LocalName.Value,
                                prop.LocalName.Value);
                            displayName = ColumnUtils.BuildPropertyDisplay(displayName, prop.TypeName);

                            lov.Add(new MappingLovEFElement(prop, displayName), displayName);
                        }
                    }
                }

                return lov;
            }
            else
            {
                Debug.Fail("Unsupported lov type (" + type.ToString() + ") was sent");
            }

            return base.GetListOfValues(type);
        }
コード例 #17
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.ThirdColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var table = MappingAssociationSet.GetTable();
                var properties = new List<Property>();
                if (table != null)
                {
                    properties.AddRange(table.Properties());
                }

                // we aren't filtering this list, show all columns of the table
                if (ScalarProperty != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (ScalarProperty == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    foreach (var prop in properties)
                    {
                        var displayName = ColumnUtils.BuildPropertyDisplay(prop.LocalName.Value, prop.TypeName);
                        lov.Add(new MappingLovEFElement(prop, displayName), displayName);
                    }
                }

                return lov;
            }

            return base.GetListOfValues(type);
        }
コード例 #18
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var entityType = MappingFunctionEntityType.EntityType;
                var cet        = entityType as ConceptualEntityType;

                Debug.Assert(entityType == null || cet != null, "EntityType is not ConceptualEntityType");

                var propsFromSelf = new List <Property>();
                var propsFromNav  = new Dictionary <NavigationProperty, HashSet <Property> >();

                // show keys for the top-most base type
                if (cet.HasResolvableBaseType)
                {
                    propsFromSelf.AddRange(entityType.ResolvableKeys);
                }

                // show all properties of the entity
                propsFromSelf.AddRange(cet.SafeInheritedAndDeclaredProperties);

                // bug 568863: we need to show any "inherited" navigation properties as well
                foreach (var selfOrBaseType in cet.SafeSelfAndBaseTypes)
                {
                    // add properties for every type referenced by a navigation property
                    foreach (var nav in selfOrBaseType.NavigationProperties())
                    {
                        if (nav.FromRole.Status == BindingStatus.Known &&
                            nav.FromRole.Target.Type.Status == BindingStatus.Known &&
                            nav.ToRole.Status == BindingStatus.Known &&
                            nav.ToRole.Target.Type.Status == BindingStatus.Known &&
                            nav.ToRole.Target.Multiplicity.Value != ModelConstants.Multiplicity_Many)
                        {
                            ConceptualEntityType other = null;
                            if (nav.FromRole.Target.Type.Target == selfOrBaseType)
                            {
                                other = nav.ToRole.Target.Type.Target as ConceptualEntityType;
                            }
                            else
                            {
                                other = nav.FromRole.Target.Type.Target as ConceptualEntityType;
                            }

                            if (!propsFromNav.ContainsKey(nav))
                            {
                                propsFromNav[nav] = new HashSet <Property>();
                            }

                            // bug 568863, only include keys from reference types
                            foreach (var key in other.ResolvableTopMostBaseType.ResolvableKeys)
                            {
                                if (!propsFromNav[nav].Contains(key))
                                {
                                    propsFromNav[nav].Add(key);
                                }
                            }
                        }
                    }
                }

                if (ScalarProperty != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (propsFromSelf.Count == 0 &&
                    propsFromNav.Count == 0)
                {
                    if (ScalarProperty == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    var displayName = String.Empty;

                    // add those remaining in our list
                    // Note: properties (even simple ScalarProperties that are not part of a ComplexProperty) are
                    //       added to the lov as a List<Property> whereas properties from the other end of a
                    //       NavigationProperty are added as a Property. This allows us to tell them apart (see
                    //       PropertyColumn.SetValue())
                    foreach (var prop in propsFromSelf)
                    {
                        ColumnUtils.AddPropertyToListOfValues(lov, prop, null);
                    }

                    var propsFromNavEnum = propsFromNav.GetEnumerator();
                    while (propsFromNavEnum.MoveNext())
                    {
                        foreach (var prop in propsFromNavEnum.Current.Value)
                        {
                            displayName = string.Format(
                                CultureInfo.CurrentCulture, "{0}.{1}",
                                propsFromNavEnum.Current.Key.LocalName.Value,
                                prop.LocalName.Value);
                            displayName = ColumnUtils.BuildPropertyDisplay(displayName, prop.TypeName);

                            lov.Add(new MappingLovEFElement(prop, displayName), displayName);
                        }
                    }
                }

                return(lov);
            }
            else
            {
                Debug.Fail("Unsupported lov type (" + type.ToString() + ") was sent");
            }

            return(base.GetListOfValues(type));
        }
コード例 #19
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.FirstColumn)
            {
                BaseEntityModel storageModel = null;
                if (ModelItem != null)
                {
                    var table = ModelItem as EntityType;
                    storageModel = table.EntityModel as StorageEntityModel;
                }
                else
                {
                    // this is a creator node, so get the list from the artifact
                    var entity = MappingConceptualEntityType.ModelItem as EntityType;
                    storageModel = entity.Artifact.StorageModel();
                }

                var entities = new List <EntityType>();
                entities.AddRange(storageModel.EntityTypes());

                // filter the list down to those tables that we aren't already mapping
                foreach (var child in MappingConceptualEntityType.Children)
                {
                    var mset = child as MappingStorageEntityType;
                    Debug.Assert(mset != null, "expected child of type MappingStorageEntityType, got type " + child.GetType().FullName);
                    if (mset.StorageEntityType != null)
                    {
                        entities.Remove(mset.StorageEntityType);
                    }
                }

                if (StorageEntityType != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (entities.Count == 0)
                {
                    if (StorageEntityType == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var entityType in entities)
                    {
                        // adding the EntityType to the list
                        lov.Add(new MappingLovEFElement(entityType, entityType.DisplayName), entityType.DisplayName);
                    }
                }

                return(lov);
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return(base.GetListOfValues(type));
        }
コード例 #20
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.FirstColumn)
            {
                var properties = new List<Property>();

                // fill our list initially with all columns
                properties.AddRange(MappingStorageEntityType.StorageEntityType.Properties());

                // filter the list down to those that aren't used in conditions. We don't filter based on properties
                // because it is useful in a TPH scenario to have the property mapped as well as used in a condition
                foreach (var child in MappingStorageEntityType.Children)
                {
                    var mc = child as MappingCondition;
                    Debug.Assert(mc != null, "expected child to be of type MappingCondition, instead got type " + child.GetType().FullName);
                    if (mc.Condition != null
                        &&
                        mc.Condition.ColumnName.Target != null
                        &&
                        properties.Contains(mc.Condition.ColumnName.Target))
                    {
                        properties.Remove(mc.Condition.ColumnName.Target);
                    }
                }

                if (Condition != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (Condition == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var column in properties)
                    {
                        lov.Add(new MappingLovEFElement(column, column.LocalName.Value), column.LocalName.Value);
                    }
                }

                return lov;
            }
            else if (type == ListOfValuesCollection.SecondColumn)
            {
                lov.Add(LovOperatorIsPlaceHolder, LovOperatorIsPlaceHolder.DisplayName);
                lov.Add(LovOperatorEqualsPlaceHolder, LovOperatorEqualsPlaceHolder.DisplayName);
                return lov;
            }
            else if (type == ListOfValuesCollection.ThirdColumn)
            {
                lov.Add(LovValueNullPlaceHolder, LovValueNullPlaceHolder.DisplayName);
                lov.Add(LovValueNotNullPlaceHolder, LovValueNotNullPlaceHolder.DisplayName);
                return lov;
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return base.GetListOfValues(type);
        }
コード例 #21
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.ThirdColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.ThirdColumn)
            {
                var properties = new List<Property>();

                var entityType = MappingFunctionEntityType.EntityType;
                var conceptualEntityType = entityType as ConceptualEntityType;

                if (conceptualEntityType != null)
                {
                    properties.AddRange(conceptualEntityType.SafeInheritedAndDeclaredProperties);
                }
                else
                {
                    properties.AddRange(entityType.Properties());
                }

                if (ResultBinding != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (ResultBinding == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var prop in properties)
                    {
                        var displayName = ColumnUtils.BuildPropertyDisplay(prop.LocalName.Value, prop.TypeName);
                        lov.Add(new MappingLovEFElement(prop, displayName), displayName);
                    }
                }

                return lov;
            }

            return base.GetListOfValues(type);
        }
コード例 #22
0
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.FirstColumn)
            {
                BaseEntityModel storageModel = null;
                if (ModelItem != null)
                {
                    var table = ModelItem as EntityType;
                    storageModel = table.EntityModel as StorageEntityModel;
                }
                else
                {
                    // this is a creator node, so get the list from the artifact
                    var entity = MappingConceptualEntityType.ModelItem as EntityType;
                    storageModel = entity.Artifact.StorageModel();
                }

                var entities = new List<EntityType>();
                entities.AddRange(storageModel.EntityTypes());

                // filter the list down to those tables that we aren't already mapping
                foreach (var child in MappingConceptualEntityType.Children)
                {
                    var mset = child as MappingStorageEntityType;
                    Debug.Assert(mset != null, "expected child of type MappingStorageEntityType, got type " + child.GetType().FullName);
                    if (mset.StorageEntityType != null)
                    {
                        entities.Remove(mset.StorageEntityType);
                    }
                }

                if (StorageEntityType != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (entities.Count == 0)
                {
                    if (StorageEntityType == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var entityType in entities)
                    {
                        // adding the EntityType to the list
                        lov.Add(new MappingLovEFElement(entityType, entityType.DisplayName), entityType.DisplayName);
                    }
                }

                return lov;
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return base.GetListOfValues(type);
        }
コード例 #23
0
        internal override Dictionary <MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary <MappingLovEFElement, string>();

            if (type == ListOfValuesCollection.FirstColumn)
            {
                var properties = new List <Property>();

                // fill our list initially with all columns
                properties.AddRange(MappingStorageEntityType.StorageEntityType.Properties());

                // filter the list down to those that aren't used in conditions. We don't filter based on properties
                // because it is useful in a TPH scenario to have the property mapped as well as used in a condition
                foreach (var child in MappingStorageEntityType.Children)
                {
                    var mc = child as MappingCondition;
                    Debug.Assert(mc != null, "expected child to be of type MappingCondition, instead got type " + child.GetType().FullName);
                    if (mc.Condition != null
                        &&
                        mc.Condition.ColumnName.Target != null
                        &&
                        properties.Contains(mc.Condition.ColumnName.Target))
                    {
                        properties.Remove(mc.Condition.ColumnName.Target);
                    }
                }

                if (Condition != null)
                {
                    // add the row at the top that the user can click on to remove the item
                    lov.Add(LovDeletePlaceHolder, LovDeletePlaceHolder.DisplayName);
                }

                if (properties.Count == 0)
                {
                    if (Condition == null)
                    {
                        lov.Add(LovEmptyPlaceHolder, LovEmptyPlaceHolder.DisplayName);
                    }
                }
                else
                {
                    // add those remaining in our list
                    foreach (var column in properties)
                    {
                        lov.Add(new MappingLovEFElement(column, column.LocalName.Value), column.LocalName.Value);
                    }
                }

                return(lov);
            }
            else if (type == ListOfValuesCollection.SecondColumn)
            {
                lov.Add(LovOperatorIsPlaceHolder, LovOperatorIsPlaceHolder.DisplayName);
                lov.Add(LovOperatorEqualsPlaceHolder, LovOperatorEqualsPlaceHolder.DisplayName);
                return(lov);
            }
            else if (type == ListOfValuesCollection.ThirdColumn)
            {
                lov.Add(LovValueNullPlaceHolder, LovValueNullPlaceHolder.DisplayName);
                lov.Add(LovValueNotNullPlaceHolder, LovValueNotNullPlaceHolder.DisplayName);
                return(lov);
            }
            else
            {
                Debug.Fail("Unsupported lov type was sent");
            }

            return(base.GetListOfValues(type));
        }
コード例 #24
0
        // <summary>
        //     Returns list of all s-side functions
        // </summary>
        internal override Dictionary<MappingLovEFElement, string> GetListOfValues(ListOfValuesCollection type)
        {
            var lov = new Dictionary<MappingLovEFElement, string>();

            Debug.Assert(type == ListOfValuesCollection.FirstColumn, "Unsupported lov type was sent");

            if (type == ListOfValuesCollection.FirstColumn)
            {
                var functionImport = FunctionImportMapping.FunctionImportName.Target;
                Debug.Assert(functionImport != null, "Couldn't find FunctionImport binding");
                if (functionImport != null)
                {
                    var storageModel = EFExtensions.StorageModel(functionImport.Artifact);

                    foreach (var function in storageModel.Functions())
                    {
                        // add the Function to the list
                        lov.Add(new MappingLovEFElement(function, function.DisplayName), function.DisplayName);
                    }

                    return lov;
                }
            }

            return base.GetListOfValues(type);
        }