public IStatement GetStatement(object commandType) { Type type = (Type)commandType; if (!statements.ContainsKey(type)) { lock (statements) { if (!statements.ContainsKey(type)) { IStatement command = attributeReader.ReadStatementAttribute(type); if (command == null) { throw AttributeException.AttributeNotFoundException(type, typeof(StatementAttribute)); } command.CreateCache(); statements.Add(type, command); } } } return(statements[type]); }
public ITable GetTable(object entityType) { Type type = (Type)entityType; if (!tables.ContainsKey(type)) { lock (tables) { if (!tables.ContainsKey(type)) { ITable table = attributeReader.ReadTableAttribute(type); if (table == null) { throw AttributeException.AttributeNotFoundException(type, typeof(TableAttribute)); } //必须要查找出RelationColumn的ColumnName foreach (IRelation relation in table.Relations.Values) { foreach (IRelationColumn relationColumn in relation.RelationColumns) { string columnName = table.Columns[relationColumn.PropertyName].ColumnName; Type foreignEntityType = (Type)(relation.ForeignEntityType); ITable t = attributeReader.ReadTableAttribute(foreignEntityType); if (t == null) { throw AttributeException.AttributeNotFoundException(foreignEntityType, typeof(TableAttribute)); } string foreignColumnName = t.Columns[relationColumn.ForeignPropertyName].ColumnName; relationColumn.ColumnName = columnName; relationColumn.ForeignColumnName = foreignColumnName; } } table.CreateCache(); tables.Add(type, table); } } } return(tables[type]); }