/// <summary>
        /// Constructor taking a metadata context, an structural type, and a parent custom type descriptor
        /// </summary>
        /// <param name="typeDescriptionContext">The <see cref="LinqToEntitiesTypeDescriptionContext"/> context.</param>
        /// <param name="edmType">The <see cref="StructuralType"/> type (can be an entity or complex type).</param>
        /// <param name="parent">The parent custom type descriptor.</param>
        public LinqToEntitiesTypeDescriptor(LinqToEntitiesTypeDescriptionContext typeDescriptionContext, StructuralType edmType, ICustomTypeDescriptor parent)
            : base(parent)
        {
            this._typeDescriptionContext = typeDescriptionContext;
            this._edmType = edmType;

            EdmMember[] timestampMembers = this._edmType.Members.Where(p => ObjectContextUtilities.IsConcurrencyTimestamp(p)).ToArray();
            if (timestampMembers.Length == 1)
            {
                this._timestampMember = timestampMembers[0];
            }

            if (edmType.BuiltInTypeKind == BuiltInTypeKind.EntityType)
            {
                // if any FK member of any association is also part of the primary key, then the key cannot be marked
                // Editable(false)
                EntityType entityType = (EntityType)edmType;
                this._foreignKeyMembers = new HashSet<EdmMember>(entityType.NavigationProperties.SelectMany(p => p.GetDependentProperties()));
                foreach (EdmProperty foreignKeyMember in this._foreignKeyMembers)
                {
                    if (entityType.KeyMembers.Contains(foreignKeyMember))
                    {
                        this._keyIsEditable = true;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Constructor taking a metadata context, an structural type, and a parent custom type descriptor
        /// </summary>
        /// <param name="typeDescriptionContext">The <see cref="LinqToEntitiesTypeDescriptionContext"/> context.</param>
        /// <param name="edmType">The <see cref="StructuralType"/> type (can be an entity or complex type).</param>
        /// <param name="parent">The parent custom type descriptor.</param>
        public LinqToEntitiesTypeDescriptor(LinqToEntitiesTypeDescriptionContext typeDescriptionContext, StructuralType edmType, ICustomTypeDescriptor parent)
            : base(parent)
        {
            this._typeDescriptionContext = typeDescriptionContext;
            this._edmType = edmType;

            EdmMember[] timestampMembers = this._edmType.Members.Where(p => ObjectContextUtilities.IsConcurrencyTimestamp(p)).ToArray();
            if (timestampMembers.Length == 1)
            {
                this._timestampMember = timestampMembers[0];
            }

            if (edmType.BuiltInTypeKind == BuiltInTypeKind.EntityType)
            {
                // if any FK member of any association is also part of the primary key, then the key cannot be marked
                // Editable(false)
                EntityType entityType = (EntityType)edmType;
                this._foreignKeyMembers = new HashSet <EdmMember>(entityType.NavigationProperties.SelectMany(p => p.GetDependentProperties()));
                foreach (EdmProperty foreignKeyMember in this._foreignKeyMembers)
                {
                    if (entityType.KeyMembers.Contains(foreignKeyMember))
                    {
                        this._keyIsEditable = true;
                        break;
                    }
                }
            }
        }
 public LinqToEntitiesDomainServiceDescriptionProvider(Type domainServiceType, Type contextType, DomainServiceDescriptionProvider parent)
     : base(domainServiceType, parent)
 {
     lock (tdpContextMap)
     {
         if (!tdpContextMap.TryGetValue(contextType, out this._typeDescriptionContext))
         {
             // create and cache a context for this provider type
             this._typeDescriptionContext = new LinqToEntitiesTypeDescriptionContext(contextType);
             tdpContextMap.Add(contextType, this._typeDescriptionContext);
         }
     }
 }
 public LinqToEntitiesDomainServiceDescriptionProvider(Type domainServiceType, Type contextType, DomainServiceDescriptionProvider parent)
     : base(domainServiceType, parent)
 {
     lock (tdpContextMap)
     {
         if (!tdpContextMap.TryGetValue(contextType, out this._typeDescriptionContext))
         {
             // create and cache a context for this provider type
             this._typeDescriptionContext = new LinqToEntitiesTypeDescriptionContext(contextType);
             tdpContextMap.Add(contextType, this._typeDescriptionContext);
         }
     }
 }