private TableProvider CreateTableProvider(EntitySet entitySet, EntityType entityType)
        {
            // Get the parent clr type
            Type       parentClrType    = null;
            EntityType parentEntityType = entityType.BaseType as EntityType;

            if (parentEntityType != null)
            {
                parentClrType = GetClrType(parentEntityType);
            }

            Type rootClrType = GetClrType(entitySet.ElementType);
            Type clrType     = GetClrType(entityType);

            _entityTypeToClrType[entityType] = clrType;

            // Normally, use the entity set name as the table name
            string tableName = entitySet.Name;

            // But in inheritance scenarios where all types in the hierarchy share the same entity set,
            // we need to use the type name instead for the table name.
            if (parentClrType != null)
            {
                tableName = entityType.Name;
            }

            EFTableProvider table = new EFTableProvider(this, entitySet, entityType, clrType, parentClrType, rootClrType, tableName);

            TableEndLookup[entityType] = table;

            return(table);
        }
        public EFColumnProvider(EntityType entityType, EFTableProvider table, EdmMember m, bool isPrimaryKey)
            : base(table) {
            EdmMember = m;
            IsPrimaryKey = isPrimaryKey;
            _table = table;
            MaxLength = 0;
            Name = EdmMember.Name;
            // 
            IsCustomProperty = false;

            // 
            var property = EdmMember as EdmProperty;

            if (property != null) {
                IsForeignKeyComponent = DetermineIsForeignKeyComponent(property);
                IsGenerated = IsServerGenerated(property);
            }

            ProcessFacets();

            var navProp = m as NavigationProperty;
            if (navProp != null) {
                _isAssociation = true;
                long key = EFAssociationProvider.BuildRelationshipKey(entityType, navProp.FromEndMember);
                ((EFDataModelProvider)table.DataModel).RelationshipEndLookup[key] = this;
            }
        }
Esempio n. 3
0
        public EFColumnProvider(EntityType entityType, EFTableProvider table, EdmMember m, bool isPrimaryKey)
            : base(table)
        {
            EdmMember    = m;
            IsPrimaryKey = isPrimaryKey;
            _table       = table;
            MaxLength    = 0;
            Name         = EdmMember.Name;
            //
            IsCustomProperty = false;

            //
            var property = EdmMember as EdmProperty;

            if (property != null)
            {
                IsForeignKeyComponent = DetermineIsForeignKeyComponent(property);
                IsGenerated           = IsServerGenerated(property);
            }

            ProcessFacets();

            var navProp = m as NavigationProperty;

            if (navProp != null)
            {
                _isAssociation = true;
                long key = EFAssociationProvider.BuildRelationshipKey(entityType, navProp.FromEndMember);
                ((EFDataModelProvider)table.DataModel).RelationshipEndLookup[key] = this;
            }
        }
        private TableProvider CreateTableProvider(EntitySet entitySet, EntityType entityType) {
            // Get the parent clr type
            Type parentClrType = null;
            EntityType parentEntityType = entityType.BaseType as EntityType;
            if (parentEntityType != null) {
                parentClrType = GetClrType(parentEntityType);
            }

            Type rootClrType = GetClrType(entitySet.ElementType);
            Type clrType = GetClrType(entityType);

            _entityTypeToClrType[entityType] = clrType;

            // Normally, use the entity set name as the table name
            string tableName = entitySet.Name;

            // But in inheritance scenarios where all types in the hierarchy share the same entity set,
            // we need to use the type name instead for the table name.
            if (parentClrType != null) {
                tableName = entityType.Name;
            }

            EFTableProvider table = new EFTableProvider(this, entitySet, entityType, clrType, parentClrType, rootClrType, tableName);
            TableEndLookup[entityType] = table;

            return table;
        }