private static OrmDbType DbType(Type t, List <Type> tableTypes, HashSet <Constraint> constraints, ITypeMapper typeMapper) { var ddlType = typeMapper.GetDbType(t); var pstmtType = PreparedStatementTypeMapper.Map(t); if (tableTypes.Any(tType => tType == t)) { ddlType = typeMapper.GetForeignKeyType(); pstmtType = PreparedStatementTypeMapper.GetForeignKeyType(); } if (constraints.Any(c => c.GetType() == typeof(Pk))) { ddlType = typeMapper.GetPrimaryKeyType(); } // because we always want to enforce enums to be text if (t.IsEnum) { ddlType = typeMapper.GetEnumType(); } return(new OrmDbType( ddlType, pstmtType )); }
public static List <Column> BuildInterimColumns(ManyToMany m, Type from, Type to, ITypeMapper typeMapper) { return(new List <Column>() { new Column( m.ForeignKeyNear, new Fk(from), new HashSet <Constraint>(), null, new OrmDbType(typeMapper.GetForeignKeyType(), PreparedStatementTypeMapper.Map(from)), true ), new Column( m.ForeignKeyFar, new Fk(to), new HashSet <Constraint>(), null, new OrmDbType(typeMapper.GetForeignKeyType(), PreparedStatementTypeMapper.Map(from)), true ) }); }
public static string BuildManyToManyDdl(string fkName, ITypeMapper typeMapper) { return($"{fkName} {typeMapper.GetForeignKeyType()} "); }