示例#1
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));
        }
示例#2
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));
        }
示例#3
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));
        }