public SimpleMappingEntity(DbTableEntityMapping tm)
 {
     TableTypeMapping = tm;
 }
Esempio n. 2
0
        internal DbTableEntityMapping GetDbTableEntityMapping(Type t)
        {
            string key = t.FullName;
            if (Cache.TypeMappings.ContainsKey(key))
                return Cache.TypeMappings[key];

            DbTableAttribute ta = t.GetDbTableAttribute();
            string tableName;

            if (ta != null && !String.IsNullOrEmpty(ta.Name))
            {
                tableName = ta.Name;
            }
            else
            {
                tableName = t.Name;
            }

            if (tableName.StartsWith("<>")) return null;
            DbTable table = GetDbTable(tableName); // DON'T use GetDbTable(Type), it's dead loop
            if (table == null) return null;

            if (ta != null)
            {
                table.DefaultAuditType = ta.AuditType;
            }

            DbTableEntityMapping tm = new DbTableEntityMapping(this, t, table);
            Cache.TypeMappings.Add(key, tm);
            Cache.TableMappings.Add(tableName, tm);

            // temporarily put here (after cached) to avoid dead loop
            tm.BuildAssociationInfo(this);

            return tm;
        }