/// <summary>
 /// Initializes a new instance of AssociationEndMember
 /// </summary>
 /// <param name="name">name of the association end member</param>
 /// <param name="endRefType">Ref type that this end refers to </param>
 /// <param name="multiplicity">multiplicity of the end</param>
 internal AssociationEndMember(
     string name,
     RefType endRefType,
     RelationshipMultiplicity multiplicity)
     : base(name, endRefType, multiplicity)
 {
 }
 /// <summary>
 /// Initializes a new instance of RelationshipEndMember
 /// </summary>
 /// <param name="name">name of the relationship end member</param>
 /// <param name="endRefType">Ref type that this end refers to </param>
 /// <param name="multiplicity">The multiplicity of this relationship end</param>
 /// <exception cref="System.ArgumentNullException">Thrown if name or endRefType arguments is null</exception>
 /// <exception cref="System.ArgumentException">Thrown if name argument is empty string</exception>
 internal RelationshipEndMember(string name, 
                                RefType endRefType,
                                RelationshipMultiplicity multiplicity)
 : base(name, 
        TypeUsage.Create(endRefType, new FacetValues{ Nullable = false }))
 {
     _relationshipMultiplicity = multiplicity;
     _deleteBehavior = OperationAction.None;
 }
Exemplo n.º 3
0
        /// <summary>
        /// The type needs an entitysetidproperty, if it is either an entity type
        /// or a reference type, AND we cannot determine that there is only entityset
        /// in the query that could be producing instances of this entity
        /// </summary>
        /// <param name="typeInfo"></param>
        /// <returns></returns>
        private bool NeedsEntitySetIdProperty(TypeInfo typeInfo)
        {
            md.EntityType entityType;
            md.RefType    refType = typeInfo.Type.EdmType as md.RefType;
            if (refType != null)
            {
                entityType = refType.ElementType as md.EntityType;
            }
            else
            {
                entityType = typeInfo.Type.EdmType as md.EntityType;
            }
            bool result = ((entityType != null) && (GetEntitySet(entityType) == null));

            return(result);
        }
Exemplo n.º 4
0
        internal override bool ResolveNameAndSetTypeUsage(Converter.ConversionCache convertedItemCache, Dictionary<Som.SchemaElement, GlobalItem> newGlobalItems)
        {
            if (_typeUsage == null)
            {
                Debug.Assert(!(_type is ScalarType));

                EdmType edmType = (EdmType)Converter.LoadSchemaElement(_type, _type.Schema.ProviderManifest, convertedItemCache, newGlobalItems);
                EntityType entityType = edmType as EntityType;

                Debug.Assert(entityType != null);

                RefType refType = new RefType(entityType);
                refType.AddMetadataProperties(this.OtherContent);
                _typeUsage = TypeUsage.Create(refType);
            }
            return true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get the list of "key" properties (in the flattened type)
        /// </summary>
        /// <returns>the key property equivalents in the flattened type</returns>
        internal IEnumerable <PropertyRef> GetKeyPropertyRefs()
        {
            md.EntityTypeBase entityType = null;
            md.RefType        refType    = null;
            if (TypeHelpers.TryGetEdmType <md.RefType>(m_type, out refType))
            {
                entityType = refType.ElementType;
            }
            else
            {
                entityType = TypeHelpers.GetEdmType <md.EntityTypeBase>(m_type);
            }

            // Walk through the list of keys of the entity type, and find their analogs in the
            // "flattened" type
            foreach (md.EdmMember p in entityType.KeyMembers)
            {
                // Eventually this could be RelationshipEndMember, but currently only properties are suppported as key members
                PlanCompiler.Assert(p is md.EdmProperty, "Non-EdmProperty key members are not supported");
                SimplePropertyRef spr = new SimplePropertyRef(p);
                yield return(spr);
            }
        }
Exemplo n.º 6
0
        private static bool TryGetCommonType(RefType refType1, RefType reftype2, out EdmType commonType)
        {
            Debug.Assert(refType1.ElementType != null && reftype2.ElementType != null);

            if (!TryGetCommonType(refType1.ElementType, reftype2.ElementType, out commonType))
            {
                return false;
            }

            commonType = new RefType((EntityType)commonType);
            return true;
        }
        protected override void Visit(RefType refType)
        {
            int index;
            if (!this.AddObjectToSeenListAndHashBuilder(refType, out index))
            {
                return;
            }

            this.AddObjectStartDumpToHashBuilder(refType, index);

            #region Inner data visit
            this.AddObjectContentToHashBuilder(refType.Identity);
            // Identity contains Name, NamespaceName and FullName

            base.Visit(refType);

            #endregion

            this.AddObjectEndDumpToHashBuilder();
        }
 protected virtual void Visit(RefType refType)
 {
     Visit(refType.BaseType);
     Visit(refType.ElementType);
 }
        /// <summary>Convert CSpace TypeMetadata into OSpace TypeMetadata</summary>
        /// <param name="clrType"></param>
        /// <returns>OSpace type metadata</returns>
        private EdmType ConvertOSpaceToCSpaceType(EdmType clrType)
        {
            EdmType cdmType = null;

            if (Helper.IsCollectionType(clrType))
            {
                EdmType elemType = ConvertOSpaceToCSpaceType(((CollectionType)clrType).TypeUsage.EdmType);
                cdmType = new CollectionType(elemType);
            }
            else if (Helper.IsRowType(clrType))
            {
                List<EdmProperty> cdmProperties = new List<EdmProperty>();
                foreach (EdmProperty column in ((RowType)clrType).Properties)
                {
                    EdmType cdmPropertyType = ConvertOSpaceToCSpaceType(column.TypeUsage.EdmType);
                    EdmProperty cdmPorperty = new EdmProperty(column.Name, TypeUsage.Create(cdmPropertyType));
                    cdmProperties.Add(cdmPorperty);
                }
                cdmType = new RowType(cdmProperties, ((RowType)clrType).InitializerMetadata);
            }
            else if (Helper.IsRefType(clrType))
            {
                cdmType = new RefType((EntityType)(ConvertOSpaceToCSpaceType(((RefType)clrType).ElementType)));
            }
            else
            {
                cdmType = ((ObjectTypeMapping)GetMap(clrType)).EdmType;
            }
            Debug.Assert((null != cdmType), "null converted clr type");
            return cdmType;
        }
        /// <summary>Convert CSpace TypeMetadata into OSpace TypeMetadata</summary>
        /// <param name="cdmType"></param>
        /// <returns>OSpace type metadata</returns>
        private EdmType ConvertCSpaceToOSpaceType(EdmType cdmType)
        {
            EdmType clrType = null;

            if (Helper.IsCollectionType(cdmType))
            {
                var elemType = ConvertCSpaceToOSpaceType(((CollectionType)cdmType).TypeUsage.EdmType);
                clrType = new CollectionType(elemType);
            }
            else if (Helper.IsRowType(cdmType))
            {
                var clrProperties = new List<EdmProperty>();
                var rowType = (RowType)cdmType;
                foreach (var column in rowType.Properties)
                {
                    var clrPropertyType = ConvertCSpaceToOSpaceType(column.TypeUsage.EdmType);
                    var clrProperty = new EdmProperty(column.Name, TypeUsage.Create(clrPropertyType));
                    clrProperties.Add(clrProperty);
                }
                clrType = new RowType(clrProperties, rowType.InitializerMetadata);
            }
            else if (Helper.IsRefType(cdmType))
            {
                clrType = new RefType((EntityType)ConvertCSpaceToOSpaceType(((RefType)cdmType).ElementType));
            }
            else if (Helper.IsPrimitiveType(cdmType))
            {
                clrType = m_objectCollection.GetMappedPrimitiveType(((PrimitiveType)cdmType).PrimitiveTypeKind);
            }
            else
            {
                clrType = ((ObjectTypeMapping)GetMap(cdmType)).ClrType;
            }
            Debug.Assert((null != clrType), "null converted clr type");
            return clrType;
        }
Exemplo n.º 11
0
 /// <summary>
 /// Initializes a new instance of AssociationEndMember
 /// </summary>
 /// <param name="name">name of the association end member</param>
 /// <param name="endRefType">Ref type that this end refers to </param>
 /// <param name="multiplicity">multiplicity of the end</param>
 internal AssociationEndMember(string name,
                               RefType endRefType,
                               RelationshipMultiplicity multiplicity)
     : base(name, endRefType, multiplicity)
 {
 }