public TableMapping(DbTableMetadata table)
 {
     //Contract.Requires(table != null);
     _table = table;
     _entityTypes = new SortedEntityTypeIndex();
     _columns = new List<ColumnMapping>();
 }
Example #2
0
        public TableMapping(EntityType table)
        {
            DebugCheck.NotNull(table);

            _table = table;
            _entityTypes = new SortedEntityTypeIndex();
            _columns = new List<ColumnMapping>();
        }
        /// <summary>
        ///     Populate the table mapping structure
        /// </summary>
        private void Analyze()
        {
            _tableMappings = new Dictionary<DbTableMetadata, TableMapping>();
            _entityTypes = new SortedEntityTypeIndex();

            foreach (var esm in _databaseMapping.EntityContainerMappings
                .SelectMany(ecm => ecm.EntitySetMappings))
            {
                foreach (var etm in esm.EntityTypeMappings)
                {
                    _entityTypes.Add(esm.EntitySet, etm.EntityType);

                    foreach (var fragment in etm.TypeMappingFragments)
                    {
                        var tableMapping = FindOrCreateTableMapping(fragment.Table);
                        tableMapping.AddEntityTypeMappingFragment(esm.EntitySet, etm.EntityType, fragment);
                    }
                }
            }
        }